So far I have been guessing my way through the types of audio/video streams and getting them mixed up with containers. For example, I have had a friend tell me that a video file which won't play on my TV will work if I can change the file extension to .avi/.mpg for example - which worked. However, when I have had the problem since, I have tried the same but with no luck.

Could someone explain which are containers and how you can have different types of audio/video files/steams within a container file?


1 Answer 1


The basics of that are actually not that complicated (while there is definitely more to know about that topic than would fit in this answer).

Take a look at that graphic you can find on the w3c-website:

Containers and file formats graphic

As you can see, the container is exactly that: a container that can contain different types of media, most notably video and audio, but also captions and metadata about the file. When you speak about a "file format", you're normally talking about the container format, after which the file extension for normal video files is named. This is why you've probably seen many video files with file extensions such as .avi, .mp4, .mkv and the likes.

When you look at the contents of this container, you will normally have at least one video and one audio track, those are referred to as "streams". Streams can be encoded using different codecs. A codec is, in layman's terms, an algorithm (or rather a set of algorithms) which is used to compress a (video or audio) stream. The more efficient the codec, the better the ratio of (video/audio) quality to file size. Two very common codecs are the H.264 (MPEG-4/AVC) codec for video and the AAC codec for audio. Those are popular because they are very efficient, thus you can have very small files with (relatively) good quality.

So to sum this up, the container is some sort of "wrapper" that contains the actual media streams. Different container formats allow for different kinds of streams. For example, the .avi-container is very limited, you can only have one audio stream and one video stream. The matroska-container (.mkv files) is a good alternative if you need more than that. Matroska is a very flexible container that allows for multiple audio streams (e.g. for different languages), subtitles and more. However, many devices (e.g. most TVs with a USB port) don't support that standard. This is where the .mp4-container (MP4 being the standard-container for the MPEG-4-standard, which is a huge topic on it's own) comes in handy, because nearly all devices can playback files that use this container format along with the H264 & AAC codecs. This combination is the most common approach for easily interchangable video files, which for example is used by most video hosting platforms such as Youtube.

Changing the file extension is generally a stupid idea. If you change an .avi file to something like .mp4, it might work on your TV in some instances, but that is just because your TV is stupid (i.e. it knows the codecs of the streams, but doesn't even try to play them if it doesn't recognise the file extension or something like that). Container format's don't behave like text-files, you can't just change the extension and expect the container format to somehow magically change as well. If you can't open a specific video file, use the VLC video player, it supports most commonly used file formats and codecs. If you want/need to watch it on a specific device such as your TV which doesn't support the codec, you can re-encode it (not a good idea, because that means quality loss) or remux it, i.e. take the individual streams and put them in different containers (which is a bit more complicated but yields better results).

  • Thank you so much! That makes a lot more sense and removes the mystery of container files so I can understand what's going on in future
    – Bendy
    Jun 23, 2015 at 21:20
  • such an answer, much wow (y)
    – kmonsoor
    Mar 1, 2016 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.