基礎知識:視頻文件格式綜述

http://bbs.chinavideo.org/redirect.php?tid=1795&goto=lastpost

 

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.

 

 

翻譯了一下,全都是意譯;如有不準確指出,還請指出,謝謝;

 

多媒體文件
----------------
多數的多媒體文件都帶有音視頻的後綴名,像.avi (Microsoft AVI 文件), .asf (a.k.a., .wmv and .wma,
共同作爲Microsoft ASF 文件), .mov (Apple Quicktime文件),
.rm (RealMedia文件)等。然而,我們卻總因爲不知道應該使用什麼應用程序比如“播放.mov文件”而感到疑惑;這個問題其實很難回答,下面給出這麼說的原因:
前一個段落中提到的所有的文件格式也是指多媒體容器格式。他們所作的就是把音視頻數據在一起打包,交錯存放,同時加入一些播放程序能夠識別的指令幫助其正確解碼數據並給最終用戶播放出來。下面是多數多媒體文件格式的一個經典的陳列:
文件頭
標題,製作者,其他的元數據信息
視頻頭
視頻解碼器FourCC標識
寬,高,顏色空間,播放幀速
音頻頭
音頻解碼器FourCC標識
比特數/採樣率,播放頻率,聲道數
文件數據
encoded audio chunk #0
音頻編碼數據塊1
encoded video chunk #0
視頻編碼數據塊1
encoded audio chunk #1
encoded video chunk #1
encoded audio chunk #2
encoded video chunk #2
encoded audio chunk #3
encoded video chunk #3
..
..

這些音視頻塊可以使用任一音頻或視頻編碼器編碼,在頭文件中有對應的FourCC標識指明所使用的編碼器。
查看參考文檔裏的嚴格的FourCC定義列表可以從一堆的東西中得到更多的有關FourCC的信息,以及他們常常在哪裏用到。
交錯
------------
交錯是多媒體文件中數據段中音視頻分別存放的過程;
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

爲什麼要這麼做呢?爲什麼不把所有的音頻數據放在文件中視頻數據的後面呢?就像下面這樣子:
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

從概念上來講,這看上去是一個可行的方案。但實際上,這卻是行不通的。我們假設這些音視頻流同屬於一塊硬盤上的同一個文件(大多數情況確是這樣),那麼物理機制上磁盤的讀磁頭就必須要在磁盤中兩塊不同的地方來回跳躍讀取。而這些塊交錯存儲的話,讀磁頭就不需要反覆尋道了;它可以在鄰近的地方讀取所有的數據了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章