Discussion:
[FFmpeg-user] let ffmpeg auto-calc height value when specifying (new) width while keeping aspect ratio?
Ben
2018-11-01 06:56:52 UTC
Permalink
Assume I want to re-encode a video.

The new video should have the same aspect ratio as the original.

I want to change the resolution of the new video to 1680 but don't want to calculate manually the corresponding height (dividable by 2).

Can I tell ffmpeg to automatically calculate the appropriate height by using the specified width and the given aspect ratio?

Thank you
Ben
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ff
Moritz Barsnick
2018-11-01 07:36:49 UTC
Permalink
Post by Ben
The new video should have the same aspect ratio as the original.
I want to change the resolution of the new video to 1680 but don't want to calculate manually the corresponding height (dividable by 2).
Can I tell ffmpeg to automatically calculate the appropriate height by using the specified width and the given aspect ratio?
Sure. Using the "scale" filter, there's the magic negative dimension:

https://ffmpeg.org/ffmpeg-filters.html#scale-1

"If one and only one of the values is -n with n >= 1, the scale
filter will use a value that maintains the aspect ratio of the input
image, calculated from the other specified dimension. After that it
will, however, make sure that the calculated dimension is divisible
by n and adjust the value if necessary."

In other words:

$ ffmpeg -i input -vf scale=1680:-2 output

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubsc

Loading...