Selim Achour.me

Video Processing in Linux

Sep 13, 2024 #linux#video

How do I rotate a video, how do I compress it, how do I extract the audio … Linux should be able to do all that out of the box or worst case by installing ffmpeg

Reducing the size of a video file

You can set the CRF (constant rate factor) which goes from 0 (no compression) to 51 (way too compressed). Default is 23.

Here we’re using 32 as an example. I like including the crf in output file to be able to compare multiple crfs.

ffmpeg -i "$i" -c:v libx264 -preset slow -crf 32 -c:a copy "$i.32.mp4"

For all *.mp4

for i in `ls *.mp4`; do 
  ffmpeg -i "$i" -c:v libx264 -preset slow -crf 34 -c:a copy "$i.34.mp4"; 
done