List of useful ffmpeg commands
Make movie twice faster:
ffmpeg -i input -filter:v “setpts=0.5*PTS” out.mp4
Make movie twice slower:
ffmpeg -i input -filter:v “setpts=2.0*PTS” out.mp4
Reverse video:
ffmpeg -i input -vf reverse out.mp4
Cut movie starting from first second, making a 2 second new movie:
ffmpeg -i input.mp4 -ss 00:00:01.0 -t 00:00:02.0 out.mp4
ffmpeg -i .\Media3.mp4 -ss 00:59 -to 21:05 Media3_trimmed.mp4
Trim and remove audio:
ffmpeg -i .\Media1.mp4 -ss 00:13 -to 01:57 -an Media1_trimmed.mp4
Movie to images every 1 sec:
ffmpeg -i input.mp4 -vf fps=1 out%d.png
Gifs higher quality:
ffmpeg -r 8 -i im%01d.jpg -vf “split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse” out.gif
Cropping a video:
ffmpeg -i in.mp4 -filter:v “crop=out_w:out_h:x:y” out.mp4
Trim and crop a video:
ffmpeg -i .\Media1.mp4 -ss 00:08 -to 00:38 -an -vf “crop=1280:1080:300:0” -y Media1-trimmed.mp4
Scaling a video:
ffmpeg -i input.mp4 -vf scale=320:-1 output.mp4
(the 320 is the width of the exported video)
Compressing a video to reduce its size:
ffmpeg -i input.mp4 -vcodec libx264 -crf 32 output.mp4
(the 32 is a free-parameter; increase it to increase the level of compression).
Concatenating videos:
first create a new text file with the videos to connect.
For example, inside ‘videos.txt’ file write:
file ‘out1.mp4’
file ‘out2.mp4’
…
and then:
ffmpeg -f concat -i videos.txt -c copy out.mp4