Re-encodes for playback almost anywhere (H.264 Baseline, 4:2:0, AAC, faststart) without resizing: for when the frame size is already right and only the encoding needs fixing, e.g. iPhone HEVC or ProRes exports headed for a web page.
Variant in the source: scale=720:720 square with -crf 23 and -c:a copy (keeps the original audio). See also web-mp4-square-600.sh.
The command
ffmpeg -i input.mov \
-vf format=yuv420p \
-c:v libx264 -crf 20 -preset veryfast -profile:v baseline -level:v 4.1 \
-c:a aac -b:a 128k \
-movflags +faststart \
output.mp4 What each part does
-vf format=yuv420p 4:2:0 chroma, which every player supports
-c:v libx264 -crf 20 -preset veryfast
-profile:v baseline -level:v 4.1
Baseline profile; level 4.1 allows up to 1080p.
Level 3.1, used in the source, only allows up
to 720p, so use it for 720p or smaller
-c:a aac -b:a 128k
-movflags +faststart playback can start before the download finishes When to use it
Useful when a clip is already the size you want on the page but its encoding won't play everywhere, such as an iPhone HEVC clip or a ProRes export. It re-encodes video and audio and leaves the frame size alone. The header explains each flag.
Skip it if the encoding is already fine and only faststart is missing; remux-faststart.sh handles that case. If the frame size also needs to change, use web-mp4-square-600.sh or fill-crop-640x480.sh. Level 4.1 only goes up to 1080p, so resize anything larger first.
Variations:
- For sources at 720p or smaller, use
-level:v 3.1, as the original note did. - Use the note's square variant:
scale=720:720with-crf 23and-c:a copyto keep the original audio. - Raise
-crffor smaller files, or lower it for higher quality.
If the encode fails or a player rejects the file, first check that the source is no larger than 1080p. Then check that its width and height are even numbers, which 4:2:0 output requires.
Notes
- Source
- ffmpeg-utilities/notes/ffmpeg-filters.txt
- Changed
- -level 3.1 → -level:v 4.1 so 1080p sources stay within the level's limits