Log in

View Full Version : Codecs vs container formats?


Rogier
3rd November 2009, 17:08
As I understand it, there are several algorithms to compress video (called 'codecs'), such as H.264, XviD, DivX, Ogg Theora, Sorensen, etc.
There are also several algorithms to compress audio, such as MP3, Ogg Vorbis, AAC, etc.

Furthermore, there are several 'container formats' in which content, compressed by some codec (as mentioned above), can be stored, such as avi, mkv, asf, mov, wmv, etc.

Question: can content compressed with a certain codec, stored in a certain container, generally be converted without any loss (i.e. without the need to re-compress the actual content) to another container format?

For example, suppose I have an .avi file which contains a H.264+AAC encoded movie. Can this be converted to a .mov file containing the same H.264+AAC data? (wrapped in a different format to meet the .mov standard I guess, but I mean essentially the same media data)

LoRd_MuldeR
3rd November 2009, 17:21
As I understand it, there are several algorithms to compress video (called 'codecs'), such as H.264, XviD, DivX, Ogg Theora, Sorensen, etc.
There are also several algorithms to compress audio, such as MP3, Ogg Vorbis, AAC, etc.

Not exactly. You must distinguish between Video Formats and Encoders/Decoders (Codecs) here!

For example MPEG-4 Visual (Part-2) is a video format. It's defined in the MPEG-4 standard. That is documents and specification, but not a software you can use. Encoders/Decoders (Codecs) are software. They implement standards. Both, DivX and Xvid, are MPEG-4 Visual (Part-2) encoders. So both of them implement the MPEG-4 standard. Internally they may use compeltely different algorithms (or pretty similar ones), but at the end they produce a valid MPEG-4 Visual (Part-2) bitstream that can be decoded by any MPEG-4 Visual (Part-2) decoder. That's because a video compression standard ("Format") only defines how a valid bitstream has to look like. It doesn't tell you how to transform an uncompressed video into such a bitstream. That's up to the Codec developers to figure out...

And the same goes for H.264. While H.264 is a video format (or "standard"), it is not a Codec. x264 is a Codec (actually it's only an encoder, not a decoder) that implements the H.264 standard in software. There are many other H.264 encoders, such as Ateme, MainConcept and so on. All of them produce a valid H.264 bistream at the end (hopefully ^^), but not all of them deliver the same quality. Some encoders use more sophisticated algorithms than others and thus produce better quality. For example x264 beats most (all?) other H.264 encoders at the moment...

Furthermore, there are several 'container formats' in which content, compressed by some codec (as mentioned above), can be stored, such as avi, mkv, asf, mov, wmv, etc.

Question: can content compressed with a certain codec, stored in a certain container, generally be converted without any loss (i.e. without the need to re-compress the actual content) to another container format?

Yes. This is possible. The process of storing (several) audio/video streams in a container is called "muxing" (multiplexing), reading individual streams from a container file is called "demuxing" (demultiplexing). Finally moving streams from one container to another one is called "re-muxing". That process is lossless, as the streams aren't re-encoded. However not any container is suitable for any audio/video format!

BTW: WMV is a video Format, WMA is an audio Format, ASF is the Container. Those ".wmv" and ".wma" files actually are ASF files that contain WMV and/or WMA streams ;)

Rogier
3rd November 2009, 17:25
Perfectly clear. Tnx a lot!

Rogier
9th November 2009, 10:20
One more question on this subject: what software do you recommend to do this?

Also, if I *do* need to re-encode the content (for example when going from a .asf with wmv+wma content, to a .mov with h.264+aac/mp3 content), what program is suitable for this?


The thing is, I've tested several such programs (you find shitloads of stuff when googling for this) but they all seem to do ridiculous things like forcing me to select a new output resolution or a new framerate (I can't even imagine how crappy that will look!) while I want to keep these the same as the original. Just converting (re-compressing) is what I need.

RunningSkittle
9th November 2009, 13:21
Just a few sections down! (how do people always miss this one!)

For muxing into mkv use mkvmerge, for mp4/mov use mp4box :)
For reencoding use one of the many gui's here:
http://forum.doom9.org/showthread.php?t=129748
(and of course other guis not on that list but are in the parent topic.)

khat17
14th November 2009, 01:28
You don't suggest some free apps like MEDIA CODER or FORMAT FACTORY?