Collection of Useful ffmpeg Commands
optimize with faststart (for mobile web)
crf (quality) goes from 0 (lossless) - 50 (very poor).
ffmpeg -i input.mp4 -crf 30 -profile:v baseline -level 3.0 -movflags +faststart -an output.mp4
ffmpeg -i input1.mp4 -c copy intermediate1.ts
ffmpeg -i input2.mp4 -c copy intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy output.mp4
ffmpeg -i <input> -vf "select=eq(n\,<framenumber>)" -vframes 1 out.png
extract first frame of video
ffmpeg -i <input> -vframes 1 output.jpeg
compress video with -crf
crf 0 = lossless | -crf 51 = highly compressed
ffmpeg -i input.mp4 -c:v libx264 -crf 60 output.mp4
convert mov to mp4
best quality (-qscale 0)
remove audio with -an
flag
ffmpeg -i input.mov -q:v 0 -an output.mp4
convert mov to mp4
best quality (-qscale 0)
scale resolution to 1/3 size
remove audio with -an
flag
ffmpeg -i input.mov -q:v 0 -vf scale=iw/3:ih/3 -an output.mp4
optimize with faststart (for mobile web)
only export first 5seconds of video.
crf (quality) goes from 0 (lossless) - 50 (very poor).
ffmpeg -i input.mp4 -crf 24 -profile:v baseline -level 3.0 -movflags +faststart -an -ss 00:00:00.0 -t 00:00:5.0 output.mp4
optimize for faststart
export entire video
half resolution (scale)
ffmpeg -i input.mp4 -crf 18 -profile:v baseline -level 3.0 -movflags +faststart -an -vf scale=w=iw/2:h=ih/2 output.mp4
ffmpeg -i input.mp4 -c:v libvpx-vp9 -minrate 500k -b:v 2000k -maxrate 2500k -pass 1 -movflags +faststart -an -f webm /dev/null && \
ffmpeg -i input.mp4 -c:v libvpx-vp9 -minrate 500k -b:v 2000k -maxrate 2500k -pass 2 -an output.webm
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 35 -b:v 0 -an output.webm
1-pass webm
first 6 seconds
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 36 -b:v 0 -an -ss 00:00:00.0 -t 00:00:5.0 output.webm