1
votes

I want to know what exactly get lost in H.264 encoding. I am encoding a video using libx264 and decode it with ffmpeg and again I encode the resulting video with libx264, with the same parameters and decode it for the second time. What I anticipate is first and second decoded videos must be the same in size and appearance, however, it's not! For example, I have 13000 bytes in first slice NAL units in the first coded frame and 12000 bytes in the second coded frames and that's odd. Because whatever lossy information existed in a frame should have been eliminated in the first encoding process and second encoding should be a process that its result same NAL units. Am I wrong or somewhere in my implementations I mistook?

1
Most lossy compression algorithms do not guarantee that decoding and re-encoding with the same parameters will result in identical output.cdhowie
Is there any official reference that issues this problem?e_soroush
What makes you think that it is a problem?cdhowie
I meant this subject!e_soroush

1 Answers

6
votes

This question is not possible to answer. Lossy codecs should really be called generationally lossy. Like a photocopier, ever generation is slightly modified. The only way to know "exactly" what will be lost, is to actually run the algorithm. Modern compression is composed of several steps. Motion estimation/compensation, quantization, loop filter and deblocking. And how much information is removed at each step is decided by the rate control algorithm. Each one of these steps may lose or even add information depending on the parameters and the content. And may even be different between implementations of the codec.