Discussion:
[FFmpeg-user] scale video filter and force_original_aspect_ratio option
James Darnley
2013-11-27 22:05:44 UTC
Permalink
Does the force_original_aspect_ratio option of the scale filter work as
described in the online docs?
One useful instance of this option is that when you know a specific
device’s maximum allowed resolution, you can use this to limit the
output video to that, while retaining the aspect ratio. For example,
device A allows 1280x720 playback, and your video is 1920x800. Using
this option (set it to decrease) and specifying 1280x720 to the
command line makes the output 1280x533.
I read that to be "If and only if the video is larger than the size you
set it will be scaled to fit within the size you set." Is that reading
wrong? I've been trying to get it to work when encoding a random set of
files, some smaller and some larger, than what I want but all are
resized to fit.

In my example below we can clearly see that a video of 704x576 is
resized up to 880x720 when I requested 1280x720 with
force_original_aspect_ratio=decrease
ffmpeg -loglevel verbose -y -i "Q:\test clips\crew_4cif.y4m" -vcodec mpeg2video -q 4 -vframes 1 -vf "scale=1280:720:force_original_aspect_ratio=decrease" temp.vob
ffmpeg version N-58485-ga12b4bd Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 26 2013 22:07:02 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 55.100 / 52. 55.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.102 / 55. 21.102
libavdevice 55. 5.101 / 55. 5.101
libavfilter 3. 91.100 / 3. 91.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Duration: N/A, bitrate: N/A
117 DAR 1408:1053, 60 fps, 60 tbr, 60 tbn, 60 tbc
:1/60 fr:60/1 sar:128/117 sws_param:flags=2
h:720 fmt:yuv420p sar:128/117 flags:0x4
encoder : Lavf55.21.102
Stream #0:0: Video: mpeg2video, yuv420p, 880x720 [SAR 128:117 DAR 1408:1053]
, q=2-31, 200 kb/s, 90k tbn, 60 tbc
Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=4.0 Lsize= 50kB time=00:00:00.01 bitrate=24575.5kbits
/s
video:46kB audio:0kB subtitle:0 global headers:0kB muxing overhead 9.096333%
ffmpeg -loglevel verbose -y -i "Q:\test clips\crew_4cif.y4m" -vcodec mpeg2video -q 4 -vframes 1 -vf "scale=1280:720:force_original_aspect_ratio=1" temp.vob
ffmpeg version N-58485-ga12b4bd Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 26 2013 22:07:02 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 55.100 / 52. 55.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.102 / 55. 21.102
libavdevice 55. 5.101 / 55. 5.101
libavfilter 3. 91.100 / 3. 91.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Duration: N/A, bitrate: N/A
117 DAR 1408:1053, 60 fps, 60 tbr, 60 tbn, 60 tbc
:1/60 fr:60/1 sar:128/117 sws_param:flags=2
h:720 fmt:yuv420p sar:128/117 flags:0x4
encoder : Lavf55.21.102
Stream #0:0: Video: mpeg2video, yuv420p, 880x720 [SAR 128:117 DAR 1408:1053]
, q=2-31, 200 kb/s, 90k tbn, 60 tbc
Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=4.0 Lsize= 50kB time=00:00:00.01 bitrate=24575.5kbits
/s
video:46kB audio:0kB subtitle:0 global headers:0kB muxing overhead 9.096333%
Lou
2013-11-28 20:06:13 UTC
Permalink
Post by James Darnley
Does the force_original_aspect_ratio option of the scale filter work as
described in the online docs?
One useful instance of this option is that when you know a specific
device’s maximum allowed resolution, you can use this to limit the
output video to that, while retaining the aspect ratio. For example,
device A allows 1280x720 playback, and your video is 1920x800. Using
this option (set it to decrease) and specifying 1280x720 to the
command line makes the output 1280x533.
I read that to be "If and only if the video is larger than the size you
set it will be scaled to fit within the size you set." Is that reading
wrong? I've been trying to get it to work when encoding a random set of
files, some smaller and some larger, than what I want but all are
resized to fit.
Also:

‘force_original_aspect_ratio’
Enable decreasing or increasing output video width or height if
necessary to keep the original aspect ratio.

Keywords "if necessary" seem to imply that smaller sized inputs will not
be increased when decrease is used, but the docs do not indicate what
occurs in this case.

I haven't looked at the code and I may be missing something (which
occurs more than I prefer), but it seems bug reportable to me.
Carl Eugen Hoyos
2013-11-29 10:14:25 UTC
Permalink
Post by Lou
‘force_original_aspect_ratio’
Enable decreasing or increasing output video width or
height if necessary to keep the original aspect ratio.
Keywords "if necessary" seem to imply that smaller sized
inputs will not be increased when decrease is used, but
the docs do not indicate what occurs in this case.
"decreasing or increasing" implies that one resolution will
always be set to the native resolution of the device, "if
necessary" means that width or height as provided by the
user will only be changed if that is necessary to keep
aspect ratio.
Post by Lou
I haven't looked at the code and I may be missing
something (which occurs more than I prefer), but it
seems bug reportable to me.
Before reporting a bug, please explain which command line
does not work as expected / as documented.
So far, everything looks as expected to me (but I may of
course be missing something).

Please remember that the bug tracker is not a support
forum (which is here).

Carl Eugen
Lou
2013-11-29 21:56:39 UTC
Permalink
Post by Carl Eugen Hoyos
"decreasing or increasing" implies that one resolution will
always be set to the native resolution of the device, "if
necessary" means that width or height as provided by the
user will only be changed if that is necessary to keep
aspect ratio.
In my opinion the docs can be made more clear and explicit; especially
since neither James nor I are unfamiliar with ffmpeg and, as far as I
can tell, we both seem to be getting a different (mis)understanding of
the docs than you. I'll submit a patch if I work on it.
Post by Carl Eugen Hoyos
Please remember that the bug tracker is not a support
forum (which is here).
I did not suggest that the bug tracker should be used as a support
forum.
James Darnley
2013-11-29 22:55:47 UTC
Permalink
Post by Lou
Post by Carl Eugen Hoyos
"decreasing or increasing" implies that one resolution will
always be set to the native resolution of the device, "if
necessary" means that width or height as provided by the
user will only be changed if that is necessary to keep
aspect ratio.
In my opinion the docs can be made more clear and explicit; especially
since neither James nor I are unfamiliar with ffmpeg and, as far as I
can tell, we both seem to be getting a different (mis)understanding of
the docs than you. I'll submit a patch if I work on it.
If I have any suggestions I'll pass them along but I don't think I can
explain it more clearly than the current text.

James Darnley
2013-11-29 22:54:05 UTC
Permalink
Post by James Darnley
Does the force_original_aspect_ratio option of the scale filter work as
described in the online docs?
One useful instance of this option is that when you know a specific
device’s maximum allowed resolution, you can use this to limit the
output video to that, while retaining the aspect ratio. For example,
device A allows 1280x720 playback, and your video is 1920x800. Using
this option (set it to decrease) and specifying 1280x720 to the
command line makes the output 1280x533.
I read that to be "If and only if the video is larger than the size you
set it will be scaled to fit within the size you set." Is that reading
wrong? I've been trying to get it to work when encoding a random set of
files, some smaller and some larger, than what I want but all are
resized to fit.
‘force_original_aspect_ratio’
Enable decreasing or increasing output video width or height if
necessary to keep the original aspect ratio.
Keywords "if necessary" seem to imply that smaller sized inputs will not
be increased when decrease is used, but the docs do not indicate what
occurs in this case.
It is slightly reassuring that it wasn't just me that read it like this.

I went on to do a little further experimenting.
In my example below we can clearly see that a video of 704x576 is
resized up to 880x720 when I requested 1280x720 with
force_original_aspect_ratio=decrease
After trying the increase value I now see what it does. With increase I
get 1280x1047. It now fits the larger dimension.
I read that to be "If and only if the video is larger than the size you
set it will be scaled to fit within the size you set." Is that reading
wrong?
So yes this reading is wrong.
Continue reading on narkive:
Search results for '[FFmpeg-user] scale video filter and force_original_aspect_ratio option' (Questions and Answers)
1.16k
replies
How would you spend $50,000 to create a more sustainable environment in Australia?
started 2007-05-13 23:16:01 UTC
green living
Loading...