I have a 1920x1080 (16:9) MP4 file with Codecs: AAC, H.264 that I would like to shrink to various smaller sizes, for example: 1280x720 or perhaps 640x360.
As far as I know, those values are clean 16:9 ratios. I'm currently using VLC Convert function to reduce them but it doesn't seem to respect 16:9 aspect ratio.
I've even tried VLC CLI to achieve it but have the same problems where it outputs something that isn't quite 16:9 by a few pixels.
For example, convert gave me: 1278x720 and 637x360. I don't see how this is possible? Even if it's not possible I would prefer black bars rather than a wrong video size as it'll cause problems.
The CLI command I tried:
vlc ./input.mp4 --intf=rc --sout \
"#transcode{vcodec=h264,acodec=none,height=360}:std{access=file,mux="ffmpeg{mux=mp4}",dst=output.mp4}"
The output from ffmpeg -i ./input.mp4 is:
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.5 (clang-1205022.9)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018年06月27日T10:24:04.000000Z
Duration: 00:00:06.81, start: 0.000000, bitrate: 15549 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 15300 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2018年06月27日T10:24:04.000000Z
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2018年06月27日T10:24:04.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
1 Answer 1
Use the scale filter:
ffmpeg -i input.mp4 -vf scale=-2:720 -c:a copy -movflags +faststart output.mp4
-2 means to automatically choose a value that preserves aspect, and makes the value divisible by 2 (needed for libx264).
-
Thank you so much. It works perfectlycreamcheese– creamcheese2021年07月15日 19:21:17 +00:00Commented Jul 15, 2021 at 19:21
You must log in to answer this question.
Explore related questions
See similar questions with these tags.
ffmpeg -i input.mp4. This won't convert anything but will show useful info about the input.