Useful ffmpeg Recipes
A few ffmpeg
commands I find useful, so I don't need to keep reading the documentation.
Contents
Convert to mp4
Converts the input to mp4 using libx264, using a quality of 35 (0-51, where o is lossless) and 256k audio compression (high quality). This video should be compatible with most devices.
ffmpeg -i "input.ext" -c:v libx264 -crf 35 -b:a 256k "output.mp4"
Concatenate
Concatenates the videos specified in file.txt
ffmpeg -f concat -safe 0 -i "file.txt" -c copy "output.ext"
The contents of file.txt
(must be single quotes)
file 'path/to/file1.ext'
file 'path/to/file2.ext'
file 'path/to/file3.ext'
...
Speed Up
Speeds up the input video 256 times, and strips the audio with -an
ffmpeg -i "input.ext" -an -filter:v "setpts=PTS/256" "output.ext"
Seek and Crop
Do the following:
-ss 10
seek to 10 seconds-t
take 4 seconds of videocrop=w=1280:h=500:x=0:y=110
take a1280×500
box at coordinate0,110
ffmpeg -ss 10 -t 4 -i "input.ext" -filter:v "crop=w=1280:h=500:x=0:y=110" "output.ext"
Resize
Resize the video to 640 pixels wide, making ffmpeg calculate the height based on the aspect ratio of the input video.
ffmpeg -i "input.ext" -vf scale=640:-1 "output.ext"
🏷️ video convert mp4 seek resize input ffmpeg crop audio recipe command documentation libx264 0-51 lossless
Please click here to load comments.