基礎知識:視頻檔案格式綜述

來源:互聯網
上載者:User

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

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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.