[FFmpeg-user] Command line to keep original aspect ration and encode to iPhone with borders

Lou lou at lrcd.com
Mon Oct 10 21:09:27 CEST 2011


On Mon, 10 Oct 2011 01:03:38 +0100
DM <dm101085 at gmail.com> wrote:

> We need a command line to keep any original aspect ration and encode
> to iPhone (.mp4), but with black borders.
> 
> We have customers uploading lots of different aspect ratio inputs,
> and only the same one command line to enable the video
> to play in any iPhone (and Android if possible)
> 
> So we can't have a command line with a changing border size, as we
> can't change the command line for each upload.

I don't own any iDevices, but you could try something like:

ffmpeg -i input -vf scale="640:trunc(ow/a/2)*2" -vcodec libx264 \
-preset medium -profile baseline -level 3.0 -crf 24 -acodec libfaac \
-aq 100 output.mp4

or:

ffmpeg -i input -vf scale="640:trunc(ow/a/2)*2" -vcodec libx264 \
-preset medium -vpre ipod640 -crf 24 -acodec libfaac -aq 100 output.mp4

You will have to test these examples to see which works best in your
device(s). The scale filter in these examples will resize your output to
640 pixels wide and will automatically use a value for the height that
preserves the aspect ratio and provides an even number for libx264 (you
could perhaps use "640:-1" with less picky encoders).

Note that "-vpre ipod640" was broken for some time, but this is fixed
in Git master. If you still want the black borders see the "pad" filter.


More information about the ffmpeg-user mailing list