I want to reduce video dimension to 720:480 & keep original aspect ration when input video width > 720 else, keep original dimension and aspect ratio.
I am trying to reproduce this script in a Windows batch file and it fails:
Resizing videos with ffmpeg/avconv to fit into static sized player
set $width=720
set $height=480
ffmpeg -i file8.3gp -vcodec libx264 -preset slow -crf 20 -filter:v "scale=iw*min($width/iw,$height/ih):ih*min($width/iw,$height/ih), pad=$width:$height:($width-iw*min($width/iw,$height/ih))/2:($height-ih*min($width/iw,$height/ih))/2" -threads 0 -acodec libvo_aacenc -b:a 128k out.mp4
The errors I'm getting:
ffmpeg -i file8.3gp -vcodec libx264 -preset slow
-crf 20 -filter:v "scale=iw*min($width/iw,$height/ih):ih*min($width/iw,$height/i
h), pad=$width:$height:($width-iw*min($width/iw,$height/ih))/2:($height-ih*min($
width/iw,$height/ih))/2" -threads 0 -acodec libvo_aacenc -b:a 128k out.mp4
ffmpeg version N-54691-g7f4a1fd Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 12 2013 16:31:48 with gcc 4.7.3 (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-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil 52. 39.100 / 52. 39.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 80.101 / 3. 80.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file8.3gp':
Metadata:
major_brand : 3gp5
minor_version : 256
compatible_brands: 3gp53gp4
creation_time : 2005-10-28 17:36:40
Duration: 00:00:04.93, start: 0.000000, bitrate: 46 kb/s
Stream #0:0(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 8 k
b/s
Metadata:
creation_time : 2005-10-28 17:36:40
handler_name : Apple Sound Media Handler
Stream #0:1(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p
, 176x144 [SAR 1:1 DAR 11:9], 35 kb/s, 15 fps, 15 tbr, 600 tbn, 1k tbc
Metadata:
creation_time : 2005-10-28 17:36:40
handler_name : Apple Video Media Handler
File 'out.mp4' already exists. Overwrite ? [y/N] y
[Parsed_scale_0 @ 0000000000318640] Invalid size 'iw*min($width/iw'
[AVFilterGraph @ 00000000024c0540] Error initializing filter 'scale' with args '
iw*min($width/iw:flags=0x4'
Error opening filters!
Invalid size 'iw*min($width/iw'
. That suggests thatffmpeg
is breaking yourscale=iw*min($width/iw,$height/ih)
expression into pieces at the comma. Now look at your command, and look at the command that you claim to be copying from –– it has backslashes before the commas. Backslash often means that the following character is special –– for example, that a comma is part of an expression, rather than a separator.