ffmpeg Cheatsheet

Last modified: March 27, 2021

Basic operations

Convert 1 image to video
ffmpeg -loop 1 -i image.png -c:v libx264 -t 30 -pix_fmt yuv420p out.mp4
Combine video and audio files
ffmpeg -i video.mp4 -i audio.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4
Concatenate videos from a text file
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
Convert from .mov to .mp4
ffmpeg -i video.mov -vcodec h264 -acodec aac output.mp4
Concat file format
file 'file1.mp4'
file 'file2.mp4'
file 'file3.mp4'
Concat videos from a list but re-encode to ensure no glitches
ffmpeg -f concat -safe 0 -i mylist.txt -c:v h264 -c:a aac output.mp4
Add N seconds to the end of the video with last frame
ffmpeg -i input.mp4 -vf tpad=stop_mode=clone:stop_duration=60 out.mp4
Generate silent audio file
ffmpeg -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -t 1 silence.mp3
Extract screenshot at specific time
ffmpeg -ss 00:01:52 -i input.mp4 -frames:v 1 -q:v 2 output.jpg