[Ffmpeg-devel] DAR and SAR FFmpeg option confusion

Benoit Fouet benoit.fouet
Mon Mar 12 17:57:16 CET 2007


Hi,

Robert Swain wrote:
> Hello,
> Benoit Fouet wrote:
>> Robert Swain wrote:
>>> ffmpeg.c:
>>> 3578:    { "aspect", HAS_ARG | OPT_VIDEO,
>>> {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or
>>> 1.3333, 1.7777)", "aspect" },
>>>
>>> libavcodec/utils.c:
>>> 579:{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio),
>>> FF_OPT_TYPE_RATIONAL, DEFAULT, 0, 10, V|E},
>> i'm not sure the one in utils.c should exist (if it is triggered, i'm
>> not sure it will lead to a good behavior)...
>> to verify this, you can try to use -vaspect option, which should use the
>> option in utils.c, and not the one in ffmpeg.c
>> there must also be a static in ffmepg.c to handle the aspect ratio,
>> which you should not use to set encoder param if you use -vaspect,
>> too...
> I'm encoding to x264 and I wrote the code in libavcodec/x264.c to use:
>
> 192:    x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
> 193:    x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
>
I don't exactly know how avctx->sample_aspect_ratio is filled...

> I haven't done any print debugging but looking at the SAR reported by
> x264, these values are not affected by -vaspect, grepping for vaspect
> in the code returns no results and it isn't documented anywhere yet
> ffmpeg doesn't report any unrecognised option error. :/
>
the point is that i just wanted to see if the "aspect" option in utils.c
worked (my guess was that it doesn't, and it seems i was right on that
point)
using "-vaspect" just triggers the "aspect" option in utils.c for video
codec (-v for video, aspect for "aspect") and not the "aspect" option in
ffmpeg.c (look at opt_default in ffmpeg.c to understand how this is handled)

>>> I tried two command lines with -aspect just after -i and another just
>>> before the output file and they exhibited the same behaviour so I
>>> assume the position on the command line doesn't affect the meaning. I
>>> think -aspect is being used for the frame aspect ratio only.
>> it is the case indeed
>>
>>> I would make a patch but I don't know how to solve this issue.
>> what issue do you think of ?
>
> The issue is that the SAR seemingly cannot be overriden.
>
if you use, for instance:
$ ffmpeg -i foo.mp4 -aspect 4:3 -vcodec h264 bar.mp4
it works, no ? (at least, it works for me...)

>>> I would like to be able to set the sample aspect ratio somehow. I'll
>>> do the monkey work if someone explains what needs changing. :)
>
> Rob
Ben





More information about the ffmpeg-devel mailing list