AVI文件格式里的一点疑问

渔民913 2004-11-10 11:19:12
一般AVI文件里的音频和视频数据是交错保存的,不知道如果写完所有视频数据再写音频的话,音视频还能不能同步?如果播放AVI文件是播放时从上到下依次读取数据,遇到音频就解音频,遇到视频就解视频的话,那么应该交错保存才能同步。但是如果播放是一来就把文件里的音频和视频数据分开,分别读取的话,那么应该就不需要交错保存了。不知道是不是这样,AVI文件播放的原理到底是怎么样的?
...全文
144 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
GoogleGeek 2004-11-10
  • 打赏
  • 举报
回复

The following may help you!
//-------------------------------------
Multimedia Files
----------------
Many multimedia files that carry both audio and video bear extensions
such as .avi (Microsoft AVI files), .asf (a.k.a., .wmv and .wma,
collectively known as Microsoft ASF files), .mov (Apple Quicktime files),
and .rm (RealMedia files). Confusion often arises as one wonders what
application can, for example, "play .mov files". That is a very difficult
question to answer and here is why:

All of the formats mentioned in the preceding paragraph are also
referred to as multimedia container formats. All they do is pack chunks
of audio and video data together, interleaved, along with some
instructions to inform a playback application how the data is to be
decoded and presented to the user. This is the typical layout of many
multimedia file formats:

file header
title, creator, other meta-info
video header
video codec FourCC
width, height, colorspace, playback framerate
audio header
audio codec FourCC
bits/sample, playback frequency, channel count
file data
encoded audio chunk #0
encoded video chunk #0
encoded audio chunk #1
encoded video chunk #1
encoded audio chunk #2
encoded video chunk #2
encoded audio chunk #3
encoded video chunk #3
..
..

Those audio and video chunks can be encoded with any number of audio or
video codecs, the FourCCs of which are specified in the file header.

See The Almost Definitive FourCC Definition List listed in the reference
for more information on the jungle of FourCCs out there, and where they
commonly appear.
Interleaving
------------
Interleaving is the process of storing alternating audio and video chunks
in the data section of a multimedia file:

encoded audio chunk #0
encoded video chunk #0
encoded audio chunk #1
encoded video chunk #1
encoded audio chunk #2
encoded video chunk #2
..
..
encoded audio chunk #n
encoded video chunk #n

Why is this done? Why not just place all of the video data in the file,
followed by all of the audio data? For example:

encoded video chunk #0
encoded video chunk #1
encoded video chunk #2
..
..
encoded video chunk #n
encoded audio chunk #0
encoded audio chunk #1
encoded audio chunk #2
..
..
encoded audio chunk #n

Conceptually, this appears to be a valid solution. In practice, however,
it falls over. Assuming these audio and video streams are part of the same
file on the same disk (almost always the case), there is a physical
mechanism called the disk read head which has to constantly make a leap
between two different positions on the disk. When the chunks are
interleaved, the read head does not need to seek at all; it can read all
the data off in a contiguous fashion.

///////////////////////////////////
You have the power to play and create anything
http://www.donews.net/ffmpeg
GoogleGeek 2004-11-10
  • 打赏
  • 举报
回复
avi的播放原理和任何别的媒体文件的播放原理相同!

你所说的问题是播放器的实现问题,与具体的文件格式没有任何的关系
播放器自己来实现video和audio的同步问题!
理论上你可以完全不用考虑数据的interlace性能,写完video后再写audio,vice versa,
但是我们知道硬盘的在实现seek功能时当然是数据越interlace效率越高了
所以大部分媒体文件在存储时都是尽量按照interlace存放的,----只是尽量而已!
而播放器并不以此来进行audio和video的同步,而是video和audio splitter后,用时间戳来同步,而时间戳无非就三种情况,
based on audio,or based on video,or based on extern timer!

ffmpeg@gmail.com
listream1 2004-11-10
  • 打赏
  • 举报
回复
用AVI SPLITTER 分离后在对音视频分别解码
happydeer 2004-11-10
  • 打赏
  • 举报
回复
音视频数据应该交错保存,时间上不能相差太大,否则播放肯定不同步。

播放时是读一块数据然后分离、分别解码的,不是先分离再解码。
渔民913 2004-11-10
  • 打赏
  • 举报
回复
诸位仁兄,帮忙解释一下啊

2,542

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧