Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: jicama on March 08, 2012, 06:48:45 PM

Title: patch: avoid lying about mp4 dimensions
Post by: jicama on March 08, 2012, 06:48:45 PM
An MP4 file encoded via HandBrake will often have a height or width that's not a multiple of 8, due to automatic cropping.  Using Avidemux 2.6 to cut a section out of such a file results in a blocky section at the bottom and/or right side of the screen that wasn't there in the input.  This turns out to be because even though the MP4 accurately describes its own dimensions, Avidemux is rounding the dimensions up to be a multiple of 8, and so playback needs to guess about what those added pixels might be.

This patch removes that rounding.
Title: Re: patch: avoid lying about mp4 dimensions
Post by: Agent_007 on March 08, 2012, 07:47:28 PM
Bump this thread in next 5 days if nobody comments this thread. (so I remember to ticket this)
Title: Re: patch: avoid lying about mp4 dimensions
Post by: nibbles on March 10, 2012, 11:48:14 AM
Jicama I thought most codecs and color spaces dealt with 8x8 blocks of pixels, doing math on their similarities, and compressing them.  If you remove part of that 8x8 block, it can't compress along that edge, and the result is undefined.  Did I miss something interesting?
Title: Re: patch: avoid lying about mp4 dimensions
Post by: jicama on March 10, 2012, 02:19:52 PM
I don't know how the codecs work, but I'd guess that when the size isn't a multiple of 8 they pad out the block with imaginary pixels for compression purposes without changing the reported size.
In any case, HandBrake is perfectly happy to create MP4s with such sizes, and players are happy to show them.
Title: Re: patch: avoid lying about mp4 dimensions
Post by: mean on March 10, 2012, 03:18:23 PM
i'll merge that when i'm back
thank!

indeed they padd the video
Title: Re: patch: avoid lying about mp4 dimensions
Post by: nibbles on March 11, 2012, 01:55:59 AM
I'm coming from a point of view where the addition of black borders to fill in a few missing pixels to make the height a multiple of 8 is a poor practice, because it yields a macroblock of 8x8 that contains a solid black bar mixed with normal video.  That doesn't compress well, and the result is chromatic aberration along the edge.

In this, case, what I was thinking about doesn't apply.  Handbrake is cropping at non-multiples of 8 and their encoder is not padding the output.  Avidemux wrongly figures things will be multiples of 8, even though they probably should be.  Thank you for crafting a patch.