LLI Wiki — My Digital Knowledge Base

Reduce the size of a video with ffmpeg

Two ffmpeg commands to reduce a video: MKV to 720p H.264 MP4 conversion, and fixed-bitrate WMV encoding.

ffmpeg can reduce the size of a video by re-encoding it. Two common cases: converting an MKV recording to a 720p H.264 MP4, and reducing a video to WMV at a fixed bitrate.

Convert an MKV to a 720p H.264 MP4

ffmpeg -i "input.mkv" -c:v libx264 -preset medium -crf 24 -vf "scale=-2:720" -c:a aac -b:a 96k "output.mp4"
Option Role
-c:v libx264 H.264 video encoding
-preset medium Trade-off between encoding speed and file size
-crf 24 Constant quality: a higher value gives a smaller file
-vf "scale=-2:720" 720 px height, width computed to keep the aspect ratio
-c:a aac -b:a 96k AAC audio at 96 kb/s

Reduce a video to WMV at a fixed bitrate

ffmpeg -i input.mp4 -b 2000k -an -vcodec wmv2 -acodec wmav2 -crf 19 -filter:v fps=fps=24 output.wmv
Option Role
-b 2000k Video bitrate of 2000 kb/s
-an Removes the audio track
-filter:v fps=fps=24 Sets the video to 24 frames per second

Notes

Mastodon LLIMastodon SocialFosstodon