多媒体文件的容器与编解码器的关系

音视频文件的格式各类繁多,但我们在说格式的时候,一般是指文件后缀,比如 .mp3 .mp4

从编程的角度来说,一个多媒体文件包含两部分,容器(container)编解码算法(codec),容器便是多媒体文件中众多数据的封装后对外的呈现,表现出来就是文件的扩展名,而编解码算法,则是播放该多媒体文件所需要和使用的算法。具体来说,

  • 容器 可看成是一个盒子,里面存放了该多媒体文件的所有信息,比如视频,包含音频和视频数据及相应所使用的编解码算法,以及其他视频相关的元数据,比如标题,作者信息,字幕文件等。同样是视频文件,如果根据所包含的音频及视频各类的不同,会形成不同的容器。容器体现在文件的扩展名上,对用户来说比较显而易见。常见的容器包括 OGG, Matroska, AVI, MPEG。

  • 编解码算法 是多媒体文件中数据所使用的编码算法,这体现在,你需要有一个支持相应编码的解码器,才能播放得了。这里算法的作用主要体现在压缩原始的媒体信息,使之在一个合理可接受的范围内,方便全输与使用。已经存在的压缩算法各类繁多,他们对不同类型的数据有各有优缺点,所以不能说哪种算法是最优的,只有最适合的。

多媒体文件中容器与编解码算法的关系示意图--图片来自 pitivi.org

多媒体文件中容器与编解码算法的关系示意图 -- 图片来自 pitivi.org

常见视频格式

以下是来自维基百科 Video file format 条目中的表格:

名称扩展名容器格式视频编码格式音频编码格式备注
WebM.webmMatroskaVP8, VP9, AV1Vorbis, OpusRoyalty-free format created for HTML5 video.
Matroska.mkvMatroskaanyany
Flash Video (FLV).flvFLVVP6, Sorenson Spark, Screen video, Screen video 2, H.264MP3, ADPCM, Nellymoser, Speex, AACUse 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).
F4V.flvMPEG-4 Part 12H.264MP3, AACReplacement for FLV.
Vob.vobVOBH.262/MPEG-2 Part 2 or MPEG-1 Part 2PCM, DTS, MPEG-1, Audio Layer II (MP2), or Dolby Digital (AC-3)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.
Ogg Video.ogv, .oggOggTheora, DiracVorbis, FLAC
Dirac.drc?Dirac?
GIF.gifN/AN/AnoneSimple animation, inefficient compression, no sound, widely supported
Video alternative to GIF.gifvHTMLanynoneNot 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.
Multiple-image Network Graphics.mngN/AN/AnoneInefficient, not widely used.
AVI.aviAVIanyanyUses RIFF
MPEG Transport Stream.MTS, .M2TSAVCHDAVCHD (MPEG-4 / H.264 )Dolby AC-3 or uncompressed linear PCMThe standard video format used by many Sony and Panasonic HD camcorders. It is also used for storing high definition video on Blu-ray discs.
QuickTime File Format.mov, .qtQuickTimemany[3]AAC, MP3, others[3]
Windows Media Video.wmvASFWindows Media Video, Windows Media Video Screen, Windows Media Video ImageWindows Media Audio, Sipro ACELP.net
Raw video format.yuvFurther documentation neededDoesn't applyDoesn't applySupports all resolutions, sampling structures, and frame rates
RealMedia (RM).rmRealMediaRealVideoRealAudioMade for RealPlayer
RealMedia Variable Bitrate (RMVB).rmvbRealMedia Variable BitrateRealVideoRealAudioMade for RealPlayer
Advanced Systems Format (ASF).asfASFanyany
AMV video format.amvModified version of AVI[4]Variant of Motion JPEGVariant of IMA, ADPCMProprietary video file format produced for MP4 players and S1 MP3 players with video playback
MPEG-4 Part 14 (MP4).mp4, .m4p (with DRM), .m4vMPEG-4 Part 12H.264, MPEG-4 Part 2, MPEG-2, MPEG-1Advanced Audio Coding, MP3, others
MPEG-1.mpg, .mp2, .mpeg, .mpe, .mpvMPEG-1 part 1MPEG-1 part 2MPEG-1 Audio Layer I, MPEG-1 Audio Layer I, MPEG-1 Audio Layer III (MP3)Old, but very widely used due to installed base.
MPEG-2 – Video.mpg, .mpeg, .m2v?H.262AAC, MP3, MPEG-2 Part 3, others
M4V – (file format for videos for iPods and PlayStation Portables developed by Apple).m4vMPEG-4 Part 12H.264AAC, Dolby DigitalDeveloped by Apple, used in iTunes. Very similar to MP4 format, but may optionally have DRM.
SVI.sviMPEG-4 utilising a special header??Samsung video format for portable players
3GPP.3gpMPEG-4 Part 12MPEG-4 Part 2, H.263, H.264AMR-NB, AMR-WB, AMR-WB+, AAC-LC, HE-AAC v1 or Enhanced aacPlus (HE-AAC v2)Common video format for cell phones
3GPP2.3g2MPEG-4 Part 12MPEG-4 Part 2, H.263, H.264AMR-NB, AMR-WB, AMR-WB+, AAC-LC, HE-AAC v1 or Enhanced aacPlus (HE-AAC v2), EVRC, SMV or VMR-WBCommon video format for cell phones
Material Exchange Format (MXF).mxfMXF??
ROQ.roq???used by Quake 3[5]
Nullsoft Streaming Video (NSV).nsvNSV??For streaming video content over the Internet
Flash Video (FLV).flv .f4v .f4p .f4a .f4bAudio, video, text, dataAdobe Flash PlatformSWF, F4V, ISO base media file formatDeveloped by the Adobe Flash Platform

常见音频格式

以下是来自维基百科 Audio file format 条目中的表格:

扩展名所属公司描述
.3gpMultimedia container format can contain proprietary formats as AMR, AMR-WB or AMR-WB+, but also some open formats
.aaAudible.com (Amazon.com)A low-bitrate audiobook container format with DRM, containing audio encoded as either MP3 or the ACELP speech codec.
.aacThe Advanced Audio Coding format is based on the MPEG-2 and MPEG-4 standards. AAC files are usually ADTS or ADIF containers.
.aaxAudible.com (Amazon.com)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.)
.actACT 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
.aiffAppleA standard uncompressed CD-quality, audio file format used by Apple. Established 3 years prior to Microsoft's uncompressed version wav.
.amrAMR-NB audio, used primarily for speech.
.apeMatthew T. AshlandMonkey's Audio lossless audio compression format.
.auSun MicrosystemsThe 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.
.awbAMR-WB audio, used primarily for speech, same as the ITU-T's G.722.2 specification.
.dctNCH SoftwareA 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.
.dssOlympusDSS 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.
.dvfSonyA Sony proprietary format for compressed voice files; commonly used by Sony dictation recorders.
.flacA file format for the Free Lossless Audio Codec, an open-source lossless compression codec.
.gsmDesigned 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.
.iklaxiKlaxAn 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.
.ivs3D Solar UK LtdA 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.
.m4aAn 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.
.m4bAn 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]
.m4pAppleA version of AAC with proprietary Digital Rights Management developed by Apple for use in music downloaded from their iTunes Music Store.
.mmfYamaha, SamsungA 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).
.mp3MPEG Layer III Audio. It is the most common sound file format used today.
.mpcMusepack 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.
.msvSonyA Sony proprietary format for Memory Stick compressed voice files.
.nmfNICENICE Media Player audio file
.nsfNintendoThe NES Sound Format (.nsf) is used for storing and playing music from the NES and related systems.[8]
.ogg, .oga, .moggXiph.Org FoundationA 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.
.opusInternet Engineering Task ForceA 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.
.ra, .rmRealNetworksA 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.
.rawA raw file can contain audio in any format but is usually used with PCM audio data. It is rarely used except for technical tests.
.slnSigned Linear PCM format used by Asterisk. Prior to v.10 the standard formats were 16-bit Signed Linear PCM sampled at 8 kHz and at 16 kHz. With v.10 many more sampling rates were added.[9]
.ttaThe True Audio, real-time lossless audio codec.
.vocCreative TechnologyThe file format consists of a 26-byte header and a series of subsequent data blocks containing the audio information
.voxThe 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.
.wavStandard 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 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.
.wmaMicrosoftWindows Media Audio format, created by Microsoft. Designed with Digital Rights Management (DRM) abilities for copy protection.
.wvFormat for wavpack files.
.webmRoyalty-free format created for HTML5 video.
.8svxElectronic ArtsThe IFF-8SVX format for 8-bit sound samples, created by Electronic Arts in 1984 at the birth of the Amiga.

相关资源

转载于:https://www.cnblogs.com/Wayou/p/media_container_and_codec.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值