Convert Video Files using ffmpeg


Reducing Size of Videos

This is a command I use to reduce the size of the video lessons we make available on the Computational Logic website:

for file in *.mp4; do ffmpeg -i $file -vf "scale=iw/2:ih/2" $(basename $file ".mp4")-small.mp4; done

The command converts all mp4 files in the current folder reducing their video size by half.

Further reduce with:

ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4

Both solutions (and others not listed here) taken from How can I reduce a video’s size with ffmpeg?

Convert to DVD

This converts to the format used in DVDs:

ffmpeg -i input.mp4 -y -target pal-dvd -sameq -aspect 16:9 output.mpeg

Extract a portion from a video

Extract a portion from a video:

ffmpeg -ss 00:00:00 -to 00:56:55 -i input.mp4 -c:v copy -c:a copy output.mp4