tl;dr
ffmpeg -i input.mp4 -vf scale=320:240,setsar=1:1 output.mp4
## variables
ffmpeg -i input.jpg -vf scale=iw*2:ih input_double_width.png
(works on images btw)
## multiple video filters
in quotes, separate with comma space:
-vf “thing1=whatever, thing2=whateverelse”.
## fit a rectangle, with padding
ffmpeg -i input.jpg -vf “scale=320:240:force_original_aspect_ratio=decrease,pad=320:240:(ow-iw)/2:(oh-ih)/2” output_320_padding.png
## text over video
found in ancient text file (might not work)
ffmpeg -i ordeal.mkv -ss 55 -t 5 -vf drawtext=“textfile=slap.txt: fontcolor=white: fontsize=96: x=(w-text_w)/2: y=(h-text_h)/2” out1.mp4; ffmpeg -i out1.mp4 -vf scale=320:180 out2.gif
## strip audio
ffmpeg -i footage_with_adamvoice.MOV -an footage.mp4
## rotate
ffmepg -i footage.mp4 -vf “transpose=2,transpose=2” rotated180.mp4
0 = 90° counterclockwise and vertical flip (default)
1 = 90° clockwise
2 = 90° counterclockwise
3 = 90° clockwise and vertical flip
## crop
To crop a 80×60 section, starting from position (200, 100):
ffmpeg -i in.mp4 -vf “crop=80:60:200:100” -c:a copy out.mp4
you can use in_h and in_w, and even things like in_h/2-100
## count frames
ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames -of csv=p=0 <input>
(src: https://stackoverflow.com/a/28376817/1173856 . he also says use “packets” instead of “frames” to go faster. “results should be the same”)
## framerate change
ffmpeg -i <input> -filter:v fps=24 <output>
## add thumbnail to file itself
ffmpeg -i video.mkv -attach cover.jpg -metadata:s:t:0 mimetype=image/jpeg -c copy out.mkv
input MUST be mkv. only mkv supports this.
thumbnail MUST be named cover.jpg or cover.png''. not “thumbnail.png”, not “cover.bmp”. you have 2 (und exactly 2!) choices: cover.jpg or cover.png.
(no, youtube will not deign to allow you to smuggle a thumbnail this way)