6

I have a video that is 720x480 (3:2) that I would like to change to 720x406 (16:9) to match the other videos I have for a site. I have tried various command combinations, including:

ffmpeg -i myfile.mv4 -s 720x406 outfile.mp4
ffmpeg -9 myfile.m4v -c copy -aspect 16:9 outfile.mp4

What I end up with is a video that scaled down to the specified height, but didn't preserve the width. It ends up at 608x406 or thereabout. I've been playing with various GUI versions of ffmpeg today, and they seem to do the same thing.

What would be the proper options/parameters to pass in (assuming I'll have more control via the command line) to achieve the desired frame size?

The command and complete console output:

$ ffmpeg -i Animation.m4v -s 720x406 Animation.mp4
ffmpeg version 2.1.2-tessus Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 13 2014 18:27:44 with llvm-gcc 4.2.1 (LLVM build 2336.1.00)
  configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --enable-runtime-cpudetect
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Animation.m4v':
  Metadata:
    major_brand     : M4VH
    minor_version   : 1
    compatible_brands: M4VHM4V M4A mp42isom
    creation_time   : 2013-10-10 22:54:24
    encoder         : Mac OS X v10.7.5 (CMA 891, CM 705.94, x86_64)
  Duration: 00:00:33.75, start: 0.000000, bitrate: 1928 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x480 [SAR 1:1 DAR 3:2], 1924 kb/s, 30 fps, 30 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      creation_time   : 2013-10-10 22:54:24
      handler_name    : Core Media Video
File 'Animation.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x102030a00] using SAR=203/240
[libx264 @ 0x102030a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0x102030a00] profile High, level 3.0
[libx264 @ 0x102030a00] 264 - core 138 r481 3a1e20c - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Animation.mp4':
  Metadata:
    major_brand     : M4VH
    minor_version   : 1
    compatible_brands: M4VHM4V M4A mp42isom
    encoder         : Lavf55.19.104
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x406 [SAR 203:240 DAR 3:2], q=-1--1, 15360 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2013-10-10 22:54:24
      handler_name    : Core Media Video
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
frame= 1013 fps=214 q=-1.0 Lsize=    1334kB time=00:00:33.70 bitrate= 324.4kbits/s    
video:1322kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.908640%
[libx264 @ 0x102030a00] frame I:5     Avg QP:13.16  size: 19296
[libx264 @ 0x102030a00] frame P:375   Avg QP:19.62  size:  2729
[libx264 @ 0x102030a00] frame B:633   Avg QP:24.13  size:   369
[libx264 @ 0x102030a00] consecutive B-frames: 13.7%  6.9%  5.9% 73.4%
[libx264 @ 0x102030a00] mb I  I16..4: 46.0% 31.9% 22.1%
[libx264 @ 0x102030a00] mb P  I16..4:  1.2%  2.3%  0.7%  P16..4: 16.4%  6.8%  3.5%  0.0%  0.0%    skip:68.9%
[libx264 @ 0x102030a00] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8: 11.6%  0.9%  0.2%  direct: 0.4%  skip:86.7%  L0:33.8% L1:61.2% BI: 5.0%
[libx264 @ 0x102030a00] 8x8 transform intra:47.9% inter:64.9%
[libx264 @ 0x102030a00] coded y,uvDC,uvAC intra: 37.8% 40.9% 17.6% inter: 4.9% 4.8% 0.9%
[libx264 @ 0x102030a00] i16 v,h,dc,p: 48% 34%  7% 11%
[libx264 @ 0x102030a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 24% 27%  2%  2%  3%  4%  4%  3%
[libx264 @ 0x102030a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 24% 16%  4%  4%  5%  6%  4%  4%
[libx264 @ 0x102030a00] i8c dc,h,v,p: 61% 21% 15%  2%
[libx264 @ 0x102030a00] Weighted P-Frames: Y:12.0% UV:7.7%
[libx264 @ 0x102030a00] ref P L0: 72.4% 14.3%  9.8%  3.4%  0.1%
[libx264 @ 0x102030a00] ref B L0: 88.2% 10.1%  1.7%
[libx264 @ 0x102030a00] ref B L1: 94.4%  5.6%
[libx264 @ 0x102030a00] kb/s:320.67
6

The answer to this question is found on Video Production Stack Exchange:

How do I change frame size, preserving width (using ffmpeg)?

Use a setdar filter to set the display aspect ratio (presentation aspect ratio):

-vf scale=720x406,setdar=16:9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.