Saqib Razzaq (SakyTalks)

My Super Helpful FFMPEG Cheatsheet

How to Add subtitles in FFMPEG

You can hardcode subtitles by providing a subtitles files and running the following command

ffmpeg -i input.mp4 -vf subtitles=subs.srt out.mp4

How to Split a video in FFMPEG

ffmpeg -i input.mp4 -ss 0 -t 300 -c copy out.mp4

Here 0 is start time in seconds and 300 is end time. This command extracts first 5 minutes of video. You can replace it with any time you need.

How to Show two videos side by side in FFMPEG

If you want to display two videos side by side like mostly done on news channels, it can be done like this

ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4

How to rotate a video by any degress using Ffmpeg

Following command can be used to rotate videos

ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=360 out.mp4

Here you can replace 360with any values e.g 180

How to Reverse a video in FFMPEG

To only reverse video ffmpeg -i input.mp4 -vf 'reverse' out.mp4

To reverse audio and video ffmpeg -i input.mp4 -vf 'reverse' -af 'areverse' out.mp4

How to Mute video in FFMPEG

You can remove audio from video with this command

ffmpeg -i input.mp4 -c copy -an out.mp4

How to Make a video greyscale in FFMPEG

You can make an entire video or a part of it greyscale.

Make full video greyscale ffmpeg -i input.mp4 -vf "hue=s=0" out.mp4

Make part of video greyscale ffmpeg -i input.mp4 -vf "hue=s=0:enable=\'between(t,3,5)\" out.mp4

How to increase video speed using FFMPEG

ffmpeg -i input -filter:v "setpts=0.5*PTS" output

You can adjust speed by changing 0.5

How to Increase or decrease audio in FFMPEG

Reduce volume by half ffmpeg -i input.wav -filter:a "volume=0.5" output.wav

Increase volume to 150% ffmpeg -i input.wav -filter:a "volume=1.5" output.wav

You can also replace 0.5 with dB

How to Generate thumbnails from video in FFMPEG

If you are running a video sharing website or a similar service, you might want to extract thumbnails from video. This is helpful to show what video represents. You can run following command for this.

ffmpeg -i input.mp4 -ss 00:00:10 -vframes 12 thumb.png

How to Flip a video horizontally or vertically in FFMPEG

Horizontally ffmpeg -i input.mp4 -vf 'hflip' out.mp4

Vertically ffmpeg -i input.mp4 -vf 'vflip' out.mp4

How to Extract video waveform in FFMPEG

Following command can be used to extract video waveform

ffmpeg -i input.mp4 -filter_complex "compand,showwavespic=s=640x120" -frames:v 1 out.png

How to Extract video waveform in FFMPEG

Following command can be used to extract video waveform

ffmpeg -i input.mp4 -filter_complex "compand,showwavespic=s=640x120" -frames:v 1 out.png

How to Extract audio of a video in FFMPEG

If you need to extract audio of a video with re-encoding the whole thing then you can run following command

ffmpeg -i input.mp4 -vn -acodec copy out.mp3

How to Add watermark in any position in FFMPEG

The base command for adding watermark looks like this

ffmpeg -i input.mp4 -i watermark.png -filter_complex "POSITION_HERE" out.mp4

You can replace POSITION_HERE with any position you need from the following

Top Right overlay=main_w-overlay_w-10:10

Top Left overlay=10:10

Bottom Right overlay=main_w-overlay_w-10:main_h-overlay_h-10

Bottom Left overlay=10:main_h-overlay_h-10

Center overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2

#ffmeg