Can compressed videos be decoded back to their uncompresed original format?

Video compression is typically "lossy", in contrast to "lossless".

This means that by compressing the data, and subsequently decompressing it, you end up with an approximation of the original that is (hopefully) acceptable for the purpose.

Storing images and video using lossy compression techniques is generally fine, because humans aren't very good at perceiving the detail in an image - for example, our brain can fill in lots of details from context alone (as our eyes only have a small area in the center that is of "high resolution"), and our eyes are more sensitive to the intensity of green than red or blue (which explains the allocation in RGB565).

So, when you say:

Does that mean that you can always extract the original large size videos from all the compressed formats like mp4?

You're asking one question, but leaving lots of openings for misinterpretation.

  • Can we extract the original, pixel-perfect image from a video compressed using lossy techniques?
    • No
  • Can we extract a single frame of a video compressed using lossy techniques that has high quality, and could be used as a static image?
    • Probably not - movement in a scene will cause a higher number of artifacts, while a static scene will typically look better and better over time.
  • Can we extract an image of the original size, that looks "reasonable" to a human?
    • Yes - for a given definition of "reasonable"

This imperfect resulting image will have "Compression Artifacts". As shown in the exaggerated examples below:

good / 100% JPEG

bad / 5% JPEG


As the comments have also focused heavily on Audio quality, the exact same thing occurs. However, audio is a significantly lower bandwidth medium, which allows for lossless codecs to be practical (for example FLAC).

Converting from PCM / WAV → MP3 → PCM will result in an output PCM file that has the artifacts introduced by the MP3 encode/decode process - these cannot be removed.

Additionally, concatenating codecs will allow each to introduce their own artifacts, and the order that the codecs are applied can have a significant effect on the output.

Converting PCM → MP3 → OGG vorbis → Opus is not the same as PCM → Opus, because each of the intermediary codecs are lossy.

I've made an example audio file which presents this as another exaggerated example. This is the first ~30 seconds of "Tonight" by "The 69 Eyes", alternating every 5 seconds between the following chains:

  • CD → FLAC → Opus
  • CD → FLAC → MP3 → Vorbis → Opus

The effect here is dramatic, with the higher frequencies (i.e: high-hat) being almost completely removed from the audio, and with significant channel (left/right) interaction that is especially noticeable at the beginning.

compare


A short answer for codecs in general:
Any lossless codec like FLAC or ZIP can be reversed exactly.
Any lossy codec like JPEG or MP3 cannot be reversed exactly.

This principle is also valid for video codecs.
Here HuffYUV is an example for a lossless video-codec.
And x264 is an example for a lossy video-codec.


Does that mean that you can always extract the original large size videos from all the compressed formats like mp4?

No. You're misinterpreting that sentence.

You can't display compressed image, just as you can't read compressed text or read file compressed with ZIP without unpacking it first. To display any image, you have to somehow represent it uncompressed in memory, pixel-for-pixel.

This doesn't imply that the uncompressed image will be identical to original - this depends on codecs used. As far as I know there are no commonly used lossless codecs. Lossy codecs aim to represent original closely enough to make the uncompressed video indistinguishable under normal circumstances, ie. when played at predicted resolution and framerate. When looking at compressed stills (ie. framerate=0) you will certainly see artifacts, unless bitrate during compression is set impractically high (ie. producing too large output files) (this answer of mine is somehow related).


By the way, MP4 is only a file format, ie. it tells you how compressed data is stored in a file, but doesn't determine how it was compressed. MP4 can work with a variety of codecs. H.264 is probably the most popular video codec used with MP4, but don't quote me on that. Audio is usually compressed with AAC, I guess.