多媒體文件的容器與編解碼器的關係

<table class="d-block"> <tbody class="d-block"> <tr class="d-block"> <td class="d-block comment-body markdown-body js-comment-body rgh-linkified-code">html

<p>音視頻文件的格式各種繁多,但咱們在說格式的時候,通常是指文件後綴,好比 <code>.mp3</code> <code>.mp4</code>。</p> <p>從編程的角度來講,一個多媒體文件包含兩部分,<a href="http://en.wikipedia.org/wiki/Digital_container_format" rel="nofollow">容器(container)</a> 與<a href="http://en.wikipedia.org/wiki/Codec" rel="nofollow">編解碼算法(codec)</a>,容器即是多媒體文件中衆多數據的封裝後對外的呈現,表現出來就是文件的擴展名,而編解碼算法,則是播放該多媒體文件所須要和使用的算法。具體來講,</p> <ul> <li> <p><strong>容器</strong> 可當作是一個盒子,裏面存放了該多媒體文件的全部信息,好比視頻,包含音頻和視頻數據及相應所使用的編解碼算法,以及其餘視頻相關的元數據,好比標題,做者信息,字幕文件等。一樣是視頻文件,若是根據所包含的音頻及視頻各種的不一樣,會造成不一樣的容器。容器體如今文件的擴展名上,對用戶來講比較顯而易見。常見的容器包括 OGG, Matroska, AVI, MPEG。</p> </li> <li> <p><strong>編解碼算法</strong> 是多媒體文件中數據所使用的編碼算法,這體如今,你須要有一個支持相應編碼的解碼器,才能播放得了。這裏算法的做用主要體如今壓縮原始的媒體信息,使之在一個合理可接受的範圍內,方便全輸與使用。已經存在的壓縮算法各種繁多,他們對不一樣類型的數據有各有優缺點,因此不能說哪一種算法是最優的,只有最適合的。</p> </li> </ul> <p><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/3783096/59859856-1fe2df80-93b0-11e9-8808-86c5770c292b.jpg"><img src="https://user-images.githubusercontent.com/3783096/59859856-1fe2df80-93b0-11e9-8808-86c5770c292b.jpg" alt="多媒體文件中容器與編解碼算法的關係示意圖--圖片來自 pitivi.org" style="max-width:100%;"></a></p> <p align="center">多媒體文件中容器與編解碼算法的關係示意圖 -- 圖片來自 <a href="http://www.pitivi.org/manual/codecscontainers.html" rel="nofollow">pitivi.org</a></p> <h2>常見視頻格式</h2> <p>如下是來自維基百科 <a href="https://en.wikipedia.org/wiki/Video_file_format" rel="nofollow">Video file format</a> 條目中的表格:</p> <table> <thead> <tr> <th>名稱</th> <th>擴展名</th> <th>容器格式</th> <th>視頻編碼格式</th> <th>音頻編碼格式</th> <th>備註</th> </tr> </thead> <tbody> <tr> <td>WebM</td> <td>.webm</td> <td>Matroska</td> <td>VP8, VP9, AV1</td> <td>Vorbis, Opus</td> <td>Royalty-free format created for HTML5 video.</td> </tr> <tr> <td>Matroska</td> <td>.mkv</td> <td>Matroska</td> <td>any</td> <td>any</td> <td></td> </tr> <tr> <td>Flash Video (FLV)</td> <td>.flv</td> <td>FLV</td> <td>VP6, Sorenson Spark, Screen video, Screen video 2, H.264</td> <td>MP3, ADPCM, Nellymoser, Speex, AAC</td> <td>Use of the H.264 and AAC compression formats in the FLV file format has some limitations and authors of Flash Player strongly encourage everyone to embrace the new standard F4V file format[2] de facto standard for web-based streaming video (over RTMP).</td> </tr> <tr> <td>F4V</td> <td>.flv</td> <td>MPEG-4 Part 12</td> <td>H.264</td> <td>MP3, AAC</td> <td>Replacement for FLV.</td> </tr> <tr> <td>Vob</td> <td>.vob</td> <td>VOB</td> <td>H.262/MPEG-2 Part 2 or MPEG-1 Part 2</td> <td>PCM, DTS, MPEG-1, Audio Layer II (MP2), or Dolby Digital (AC-3)</td> <td>Files in VOB format have .vob filename extension and are typically stored in the VIDEO_TS folder at the root of a DVD. The VOB format is based on the MPEG program stream format.</td> </tr> <tr> <td>Ogg Video</td> <td>.ogv, .ogg</td> <td>Ogg</td> <td>Theora, Dirac</td> <td>Vorbis, FLAC</td> <td></td> </tr> <tr> <td>Dirac</td> <td>.drc</td> <td>?</td> <td>Dirac</td> <td>?</td> <td></td> </tr> <tr> <td>GIF</td> <td>.gif</td> <td>N/A</td> <td>N/A</td> <td>none</td> <td>Simple animation, inefficient compression, no sound, widely supported</td> </tr> <tr> <td>Video alternative to GIF</td> <td>.gifv</td> <td>HTML</td> <td>any</td> <td>none</td> <td>Not standardized, and not a real video file in the classical meaning since it merely references the real video file (e.g. a .webm file), which has to exist separately elsewhere. A .gifv "file" is simply a HTML webpage which includes a HTML5 video tag, where the video has no sound. As there were large communities online which create art using the medium of short soundless videos in GIF format, GIFV was created as a functionally similar replacement with vastly smaller filesizes than the inefficient GIF format.</td> </tr> <tr> <td>Multiple-image Network Graphics</td> <td>.mng</td> <td>N/A</td> <td>N/A</td> <td>none</td> <td>Inefficient, not widely used.</td> </tr> <tr> <td>AVI</td> <td>.avi</td> <td>AVI</td> <td>any</td> <td>any</td> <td>Uses RIFF</td> </tr> <tr> <td>MPEG Transport Stream</td> <td>.MTS, .M2TS</td> <td>AVCHD</td> <td>AVCHD (MPEG-4 / H.264 )</td> <td>Dolby AC-3 or uncompressed linear PCM</td> <td>The standard video format used by many Sony and Panasonic HD camcorders. It is also used for storing high definition video on Blu-ray discs.</td> </tr> <tr> <td>QuickTime File Format</td> <td>.mov, .qt</td> <td>QuickTime</td> <td>many[3]</td> <td>AAC, MP3, others[3]</td> <td></td> </tr> <tr> <td>Windows Media Video</td> <td>.wmv</td> <td>ASF</td> <td>Windows Media Video, Windows Media Video Screen, Windows Media Video Image</td> <td>Windows Media Audio, Sipro ACELP.net</td> <td></td> </tr> <tr> <td>Raw video format</td> <td>.yuv</td> <td>Further documentation needed</td> <td>Doesn't apply</td> <td>Doesn't apply</td> <td>Supports all resolutions, sampling structures, and frame rates</td> </tr> <tr> <td>RealMedia (RM)</td> <td>.rm</td> <td>RealMedia</td> <td>RealVideo</td> <td>RealAudio</td> <td>Made for RealPlayer</td> </tr> <tr> <td>RealMedia Variable Bitrate (RMVB)</td> <td>.rmvb</td> <td>RealMedia Variable Bitrate</td> <td>RealVideo</td> <td>RealAudio</td> <td>Made for RealPlayer</td> </tr> <tr> <td>Advanced Systems Format (ASF)</td> <td>.asf</td> <td>ASF</td> <td>any</td> <td>any</td> <td></td> </tr> <tr> <td>AMV video format</td> <td>.amv</td> <td>Modified version of AVI[4]</td> <td>Variant of Motion JPEG</td> <td>Variant of IMA, ADPCM</td> <td>Proprietary video file format produced for MP4 players and S1 MP3 players with video playback</td> </tr> <tr> <td>MPEG-4 Part 14 (MP4)</td> <td>.mp4, .m4p (with DRM), .m4v</td> <td>MPEG-4 Part 12</td> <td>H.264, MPEG-4 Part 2, MPEG-2, MPEG-1</td> <td>Advanced Audio Coding, MP3, others</td> <td></td> </tr> <tr> <td>MPEG-1</td> <td>.mpg, .mp2, .mpeg, .mpe, .mpv</td> <td>MPEG-1 part 1</td> <td>MPEG-1 part 2</td> <td>MPEG-1 Audio Layer I, MPEG-1 Audio Layer I, MPEG-1 Audio Layer III (MP3)</td> <td>Old, but very widely used due to installed base.</td> </tr> <tr> <td>MPEG-2&nbsp;– Video</td> <td>.mpg, .mpeg, .m2v</td> <td>?</td> <td>H.262</td> <td>AAC, MP3, MPEG-2 Part 3, others</td> <td></td> </tr> <tr> <td>M4V&nbsp;– (file format for videos for iPods and PlayStation Portables developed by Apple)</td> <td>.m4v</td> <td>MPEG-4 Part 12</td> <td>H.264</td> <td>AAC, Dolby Digital</td> <td>Developed by Apple, used in iTunes. Very similar to MP4 format, but may optionally have DRM.</td> </tr> <tr> <td>SVI</td> <td>.svi</td> <td>MPEG-4 utilising a special header</td> <td>?</td> <td>?</td> <td>Samsung video format for portable players</td> </tr> <tr> <td>3GPP</td> <td>.3gp</td> <td>MPEG-4 Part 12</td> <td>MPEG-4 Part 2, H.263, H.264</td> <td>AMR-NB, AMR-WB, AMR-WB+, AAC-LC, HE-AAC v1 or Enhanced aacPlus (HE-AAC v2)</td> <td>Common video format for cell phones</td> </tr> <tr> <td>3GPP2</td> <td>.3g2</td> <td>MPEG-4 Part 12</td> <td>MPEG-4 Part 2, H.263, H.264</td> <td>AMR-NB, AMR-WB, AMR-WB+, AAC-LC, HE-AAC v1 or Enhanced aacPlus (HE-AAC v2), EVRC, SMV or VMR-WB</td> <td>Common video format for cell phones</td> </tr> <tr> <td>Material Exchange Format (MXF)</td> <td>.mxf</td> <td>MXF</td> <td>?</td> <td>?</td> <td></td> </tr> <tr> <td>ROQ</td> <td>.roq</td> <td>?</td> <td>?</td> <td>?</td> <td>used by Quake 3[5]</td> </tr> <tr> <td>Nullsoft Streaming Video (NSV)</td> <td>.nsv</td> <td>NSV</td> <td>?</td> <td>?</td> <td>For streaming video content over the Internet</td> </tr> <tr> <td>Flash Video (FLV)</td> <td>.flv .f4v .f4p .f4a .f4b</td> <td>Audio, video, text, data</td> <td>Adobe Flash Platform</td> <td>SWF, F4V, ISO base media file format</td> <td>Developed by the Adobe Flash Platform</td> </tr> </tbody> </table> <h2>常見音頻格式</h2> <p>如下是來自維基百科 <a href="https://en.wikipedia.org/wiki/Audio_file_format" rel="nofollow">Audio file format</a> 條目中的表格:</p> <table> <thead> <tr> <th>擴展名</th> <th>所屬公司</th> <th>描述</th> </tr> </thead> <tbody> <tr> <td>.3gp</td> <td></td> <td>Multimedia container format can contain proprietary formats as AMR, AMR-WB or AMR-WB+, but also some open formats</td> </tr> <tr> <td>.aa</td> <td>Audible.com (Amazon.com)</td> <td>A low-bitrate audiobook container format with DRM, containing audio encoded as either MP3 or the ACELP speech codec.</td> </tr> <tr> <td>.aac</td> <td></td> <td>The Advanced Audio Coding format is based on the MPEG-2 and MPEG-4 standards. AAC files are usually ADTS or ADIF containers.</td> </tr> <tr> <td>.aax</td> <td>Audible.com (Amazon.com)</td> <td>An Audiobook format, which is a variable-bitrate (allowing high quality) M4B file encrypted with DRM. MPB contains AAC or ALAC encoded audio in an MPEG-4 container. (More details below.)</td> </tr> <tr> <td>.act</td> <td></td> <td>ACT is a lossy ADPCM 8 kbit/s compressed audio format recorded by most Chinese MP3 and MP4 players with a recording function, and voice recorders</td> </tr> <tr> <td>.aiff</td> <td>Apple</td> <td>A standard uncompressed CD-quality, audio file format used by Apple. Established 3 years prior to Microsoft's uncompressed version wav.</td> </tr> <tr> <td>.amr</td> <td></td> <td>AMR-NB audio, used primarily for speech.</td> </tr> <tr> <td>.ape</td> <td>Matthew T. Ashland</td> <td>Monkey's Audio lossless audio compression format.</td> </tr> <tr> <td>.au</td> <td>Sun Microsystems</td> <td>The standard audio file format used by Sun, Unix and Java. The audio in au files can be PCM or compressed with the μ-law, a-law or G729 codecs.</td> </tr> <tr> <td>.awb</td> <td></td> <td>AMR-WB audio, used primarily for speech, same as the ITU-T's G.722.2 specification.</td> </tr> <tr> <td>.dct</td> <td>NCH Software</td> <td>A variable codec format designed for dictation. It has dictation header information and can be encrypted (as may be required by medical confidentiality laws). A proprietary format of NCH Software.</td> </tr> <tr> <td>.dss</td> <td>Olympus</td> <td>DSS files are an Olympus proprietary format. It is a fairly old and poor codec. GSM or MP3 are generally preferred where the recorder allows. It allows additional data to be held in the file header.</td> </tr> <tr> <td>.dvf</td> <td>Sony</td> <td>A Sony proprietary format for compressed voice files; commonly used by Sony dictation recorders.</td> </tr> <tr> <td>.flac</td> <td></td> <td>A file format for the Free Lossless Audio Codec, an open-source lossless compression codec.</td> </tr> <tr> <td>.gsm</td> <td></td> <td>Designed for telephony use in Europe, gsm is a very practical format for telephone quality voice. It makes a good compromise between file size and quality. Note that wav files can also be encoded with the gsm codec.</td> </tr> <tr> <td>.iklax</td> <td>iKlax</td> <td>An iKlax Media proprietary format, the iKlax format is a multi-track digital audio format allowing various actions on musical data, for instance on mixing and volumes arrangements.</td> </tr> <tr> <td>.ivs</td> <td>3D Solar UK Ltd</td> <td>A proprietary version with Digital Rights Management developed by 3D Solar UK Ltd for use in music downloaded from their Tronme Music Store and interactive music and video player.</td> </tr> <tr> <td>.m4a</td> <td></td> <td>An audio-only MPEG-4 file, used by Apple for unprotected music downloaded from their iTunes Music Store. Audio within the m4a file is typically encoded with AAC, although lossless ALAC may also be used.</td> </tr> <tr> <td>.m4b</td> <td></td> <td>An Audiobook / podcast extension with AAC or ALAC encoded audio in an MPEG-4 container. Both M4A and M4B formats can contain metadata including chapter markers, images, and hyperlinks, but M4B allows "bookmarks" (remembering the last listening spot), whereas M4A does not.[7]</td> </tr> <tr> <td>.m4p</td> <td>Apple</td> <td>A version of AAC with proprietary Digital Rights Management developed by Apple for use in music downloaded from their iTunes Music Store.</td> </tr> <tr> <td>.mmf</td> <td>Yamaha, Samsung</td> <td>A Samsung audio format that is used in ringtones. Developed by Yamaha (SMAF stands for "Synthetic music Mobile Application Format", and is a multimedia data format invented by the Yamaha Corporation, .mmf file format).</td> </tr> <tr> <td>.mp3</td> <td></td> <td>MPEG Layer III Audio. It is the most common sound file format used today.</td> </tr> <tr> <td>.mpc</td> <td></td> <td>Musepack or MPC (formerly known as MPEGplus, MPEG+ or MP+) is an open source lossy audio codec, specifically optimized for transparent compression of stereo audio at bitrates of 160–180 kbit/s.</td> </tr> <tr> <td>.msv</td> <td>Sony</td> <td>A Sony proprietary format for Memory Stick compressed voice files.</td> </tr> <tr> <td>.nmf</td> <td>NICE</td> <td>NICE Media Player audio file</td> </tr> <tr> <td>.nsf</td> <td>Nintendo</td> <td>The NES Sound Format (.nsf) is used for storing and playing music from the NES and related systems.[8]</td> </tr> <tr> <td>.ogg, .oga, .mogg</td> <td>Xiph.Org Foundation</td> <td>A free, open source container format supporting a variety of formats, the most popular of which is the audio format Vorbis. Vorbis offers compression similar to MP3 but is less popular. Mogg, the "Multi-Track-Single-Logical-Stream Ogg-Vorbis", is the multi-channel or multi-track Ogg file format.</td> </tr> <tr> <td>.opus</td> <td>Internet Engineering Task Force</td> <td>A lossy audio compression format developed by the Internet Engineering Task Force (IETF) and made especially suitable for interactive real-time applications over the Internet. As an open format standardised through RFC 6716, a reference implementation is provided under the 3-clause BSD license.</td> </tr> <tr> <td>.ra, .rm</td> <td>RealNetworks</td> <td>A RealAudio format designed for streaming audio over the Internet. The .ra format allows files to be stored in a self-contained fashion on a computer, with all of the audio data contained inside the file itself.</td> </tr> <tr> <td>.raw</td> <td></td> <td>A raw file can contain audio in any format but is usually used with PCM audio data. It is rarely used except for technical tests.</td> </tr> <tr> <td>.sln</td> <td></td> <td>Signed Linear PCM format used by Asterisk. Prior to v.10 the standard formats were 16-bit Signed Linear PCM sampled at 8&nbsp;kHz and at 16&nbsp;kHz. With v.10 many more sampling rates were added.[9]</td> </tr> <tr> <td>.tta</td> <td></td> <td>The True Audio, real-time lossless audio codec.</td> </tr> <tr> <td>.voc</td> <td>Creative Technology</td> <td>The file format consists of a 26-byte header and a series of subsequent data blocks containing the audio information</td> </tr> <tr> <td>.vox</td> <td></td> <td>The vox format most commonly uses the Dialogic ADPCM (Adaptive Differential Pulse Code Modulation) codec. Similar to other ADPCM formats, it compresses to 4-bits. Vox format files are similar to wave files except that the vox files contain no information about the file itself so the codec sample rate and number of channels must first be specified in order to play a vox file.</td> </tr> <tr> <td>.wav</td> <td></td> <td>Standard audio file container format used mainly in Windows PCs. Commonly used for storing uncompressed (PCM), CD-quality sound files, which means that they can be large in size—around 10&nbsp;MB per minute. Wave files can also contain data encoded with a variety of (lossy) codecs to reduce the file size (for example the GSM or MP3 formats). Wav files use a RIFF structure.</td> </tr> <tr> <td>.wma</td> <td>Microsoft</td> <td>Windows Media Audio format, created by Microsoft. Designed with Digital Rights Management (DRM) abilities for copy protection.</td> </tr> <tr> <td>.wv</td> <td></td> <td>Format for wavpack files.</td> </tr> <tr> <td>.webm</td> <td></td> <td>Royalty-free format created for HTML5 video.</td> </tr> <tr> <td>.8svx</td> <td>Electronic Arts</td> <td>The IFF-8SVX format for 8-bit sound samples, created by Electronic Arts in 1984 at the birth of the Amiga.</td> </tr> </tbody> </table> <h2>相關資源</h2> <ul> <li><a href="http://www.pitivi.org/manual/codecscontainers.html" rel="nofollow">Understanding codecs and containers</a></li> <li><a href="https://en.wikipedia.org/wiki/Video_file_format" rel="nofollow">Video file format</a></li> <li><a href="https://en.wikipedia.org/wiki/Audio_file_format" rel="nofollow">Audio file format</a></li> </ul> </td> </tr> </tbody> </table>git

相關文章
相關標籤/搜索