Do video containers affect video quality ? Or is it just the codec?

2

Do video or audio file containers (extensions) have any repercussion with the video in itself ? Or is the codec used the only thing that has a repercussion ?

For example I have the exact same video source compressed with the same codec, let's say VP9. If I put this video in a container .mp4 or .mkv or .avi or .webm, will it have a repercussion on the video depending on the container I'll have used ?

Can some codecs only be used with some containers and vice versa ?

To be sure I understand, a codec is used to compress a video or an audio in order to reduce its quality or its size (less Bytes). But do we have to use a codec ? Can't we just read a "pure" video without compression without having applied a codec ?

Nicryc

Posted 2019-12-18T21:00:48.340

Reputation: 293

1"Can't we just read a "pure" video" sadly not. A "pure" video stream would be the RAW data from the camera sensor which is a) gigantic in size, b) only understood by specific software that knows how that sensor formats data and c) un-modified and un-corrected. In the same way that the thoughts in our head need to be written down in a language (English, German, Esparanto) media needs to be encoded (MP4, JPG, WAV, etc) – Mark Henderson – 2019-12-18T21:41:52.553

Answers

1

Though there are uncompressed video formats, primarily used while recording or displaying the video, the amount of information is too large for general use. For example, 24-bit images displayed at 1080p, 60 fps is ~ 3 gigabits/second. That can be pushed through a short HDMI cable, but not efficiently stored.

Lossy compression schemes, such as MPEG, compress data but drop some visual information in the process. Lossless video compression, e.g. AV1 (that's "AVone", not "AVI") loses no data, i.e. the uncompressed stream is identical to that which was recorded.

BTW, most lossy compression schemes allow varying the amount of data lost, letting the user decide whether disk space or fidelity is relatively more important.

The file extension, which you term "container", is almost irrelevant. Some OS's ignore the extension entirely, and look only for identifying information inside the file. For example, a particular MP4 file looks like this in a hex editor:

MP4 file initial bytes

The MP4 signature format specifies the type and subtype, the length of chunks, etc. The computer identifies the type of file from that signature and then chooses a codec, designed for that file type, to decode the data.

DrMoishe Pippik

Posted 2019-12-18T21:00:48.340

Reputation: 13 291

1While the file extension is commonly used to refer to a specific container format, the identifying information inside the file is an actual part of the "container" as the term is commonly understood. This is actually the first post I've seen to claim that "container" means the file extension and nothing else. – user1686 – 2019-12-19T05:33:23.720

So can I conclude that no matter which container I use, the quality of the video will not be affected ? That if I convert a video to another format with ffmpeg, the quality will not be affected ? – Nicryc – 2019-12-19T14:00:32.940

No. Lossy compression loses info, lossless does not. – DrMoishe Pippik – 2019-12-19T20:43:37.800