[FFmpeg-devel] [PATCH 1/4] Correctly set Display Aspect Ratio in nvenc.
philipl at overt.org
Wed Jan 7 20:12:23 CET 2015
On Wed, 7 Jan 2015 10:46:47 -0800
Philip Langdale <philipl at overt.org> wrote:
> Honestly, I don't understand what the encoder is doing at this point.
> The 1.02 seems to be the 'correct' scale factor for a PAL DVD, but is
> incorrect for anything else. I used 1024 to avoid the floating point
> problem, but you are right that pre-multiplication is a better way to
> handle that. Right now I'm playing around with an NTSC DVD and I can't
> find the right magic to stop it mangling the aspect ratio.
> At this point, I'm not convinced that darWidth and darHeight are even
> representing the display presentation size at all. Hopefully Agatha
> can understand what's going on here.
Now, here's something weird. I set the darWidth and darHeight to '1' and
ffprobe reports this:
Stream #0:0(eng): Video: h264 (Main), yuv420p, 720x480 [SAR 15:22 DAR
45:44], SAR 186:157 DAR 279:157, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
Note how it somehow ends up with 45:44 for the DAR, which happens to be
1.02 - so that's where that comes from. I have no idea where the SAR
Alright, so we now have a situation where we need to compensate for this
1.02 scale factor in our dar calculation. We need to scale up the
width/height values enough that heigh * 1.02 is an integer - hence why
the 1024 helped previously.
So, for our NTSC dvd case, I might use darWidth=8520, darHeight=4896 and
this will correctly compensate.
ffprobe now reports: [SAR 1775:1496 DAR 5325:2992] which is close enough
that mplayer (for example) will correctly derive 852x480 for the display
This is crazy, but it's clearly what the encoder is doing.
More information about the ffmpeg-devel