How to reduce the size of a 1080p mp4 vid file by downsizing to 480p mp4 format, using ffmpeg
I have a bunch of mp4 format video files to be uploaded and made available online for consumption of friends and family. The preliminary review of files show, they are over one GB each and their length is between 20-30 minutes each.
Knowing from my recorded TV viewing experience, a 480p video of such duration can fit into less than 300 MB size mp4 file.
I want to convert these videos to 480p format and the tool I want to use is ffmpeg. Because, it is free to use and it is command line, so I can stuff the commands in a batch file and fire it and forget for a few days if necessary.
I searched for help regarding using ffmpeg to accomplish my goals, but being a video processing novice is not helping. Every command I found so far are failing due to not finding this or that.
My ffprobe command on one of these files returns this information:
ffprobe version 4.0.2 Copyright (c) 2007-2018 the FFmpeg developers
built with gcc 7.3.1 (GCC) 20180722
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid1080.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:31:45.44, start: 0.000000, bitrate: 4950 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 4689 kb/s, 23.98 fps, 23.98 tbr, 16k tbn, 47.95 tbc (defaul
t)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: eac3 (ec-3 / 0x332D6365), 48000 Hz, 5.1(side), fltp
, 256 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
audio service type: main
How can I accomplish this with codecs I already have on my system?
Solution 1:
This batch file should convert every movie in a folder you drag and drop to the batch file to 480p. But you have to add ffmpeg to the %path% variable for it to work. It should create a new file with the same name as the old one except with *_New480p.mp4 at the end.
@echo off
if not exist "%~1\" (exit) else (set "Folder=%~1")
pushd "%Folder%"
for %%a in (*.mp4 *.avi *.mkv) do ffmpeg -i "%%a" -vf "scale=-2:480" -c:v libx264 -c:a copy "%%~na_New480p.mp4"