简体   繁体   English

mpeg 2 解码

[英]mpeg 2 decoding

I want to understand how video and audio decoding works, specially the timing synchronization (how to get 30fps video, how to couple that with audio, etc.).我想了解视频和音频解码的工作原理,特别是时序同步(如何获得 30fps 视频,如何将其与音频结合等)。 I don't want to know ALL the details, just the essence of it.我不想知道所有的细节,只想知道它的本质。 I want to be able to write a high level simplification of an actual video/audio decoder.我希望能够编写实际视频/音频解码器的高级简化。

Could you provide pointers to me?你能给我指点迷津吗? An actual C/C++ source code of a MPEG2 video/audio decoder would be the fastest way to understand those things I think. MPEG2 视频/音频解码器的实际 C/C++ 源代码将是理解我认为的那些东西的最快方法。

Reading source code from a codec that works seems the right way to go.从有效的编解码器中读取源代码似乎是正确的方法。 I suggest the following :我建议如下:

http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html

Given that it's mentionned on the mpeg.org website, i'd say you'll find what you need here.鉴于在 mpeg.org 网站上提到了它,我想说你会在这里找到你需要的东西。

In the past i've had some time to work on decoding mpeg videos (no audio though), and the principles are quite simple.在过去,我有一些时间来解码 mpeg 视频(虽然没有音频),而且原理非常简单。 There are some pure images included, some intermediary images that are described relatively to the closest main ones, and the rest are described using the closest main/intermediary images.其中包括一些纯图像,一些中间图像相对于最接近的主图像进行描述,其余的使用最接近的主/中间图像进行描述。

One time slot, one image.一个时间段,一张图片。 But recent codecs are much more complicated, I guess !但是最近的编解码器要复杂得多,我猜!

EDIT : synchronization编辑:同步

I am no expert in synchronizing audio and video, but the issue seems to be dealt with using a sync layer (see there for a definition).我不是同步音频和视频的专家,但这个问题似乎是使用同步层来处理的(参见那里的定义)。

For audio/video synchronization, basically, every video and audio frame should be time-stamped.对于音频/视频同步,基本上,每个视频和音频帧都应该有时间戳。 The timestamp is typically known as PTS (Presentation Time Stamp).时间戳通常称为 PTS(演示时间戳)。 Once a video/audio is decoder by decoder, the audio/video renderer should schedule the frame to be displayed at the right time so that audio/video is synchronized.一旦一个视频/音频被一个解码器解码,音频/视频渲染器应该安排在正确的时间显示的帧,以便音频/视频同步。

I think you can refer to chapter " Timing Model " of MPEG2 Tutorial for details.我想你可以参考MPEG2教程的时序模型”一章了解详细信息。

您可以浏览ffmpeg 的源代码(可通过 svn 获得)或其API 文档

Depending on how much you know about MPEG-2 format, you might want to get a broad overview by reading an article about it first.根据您对 MPEG-2 格式的了解程度,您可能希望先阅读一篇有关它的文章,以获得广泛的概述。 I mean something like these:我的意思是这样的:

A Beginners Guide for MPEG-2 Standard MPEG-2 标准初学者指南

MPEG-2 VIDEO COMPRESSION MPEG-2 视频压缩

@ Patric and Nils @帕特里克和尼尔斯

So you say that there are timestamps, hein... These are for the video part only I guess.所以你说有时间戳,嘿...这些只是我猜的视频部分。 For audio I guess there is enough information in the header (like "samples per second").对于音频,我猜标题中有足够的信息(例如“每秒样本数”)。 How often these time stamps are needed?多久需要这些时间戳? I imagine that interlacing of audio and video packets ensures that video data is always ahead of audio data or something?我想音频和视频数据包的交错可以确保视频数据总是在音频数据之前?

EDIT: Found what I needed: http://www.dranger.com/ffmpeg/tutorial01.html编辑:找到我需要的: http : //www.dranger.com/ffmpeg/tutorial01.html

Helltone,海通,

Timestamps for audio data are still necessary because the audio and video frame may not be aligned at the same place.音频数据的时间戳仍然是必要的,因为音频和视频帧可能不在同一位置对齐。 For example:例如:

V: 1000 1040 1080 1120 ... A: 990 1013 1036 (lost) 1082 V:1000 1040 1080 1120 ... A:990 1013 1036(丢失)1082

You may need to compensate the offset between the first video/audio frame.您可能需要补偿第一个视频/音频帧之间的偏移。 Besides, if it is possible that there are packet loss (during video streaming), you need the timestamps of both video/audio to keep accurate synchronization.此外,如果可能存在丢包(在视频流期间),您需要视频/音频的时间戳以保持准确同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM