Skip to content

Instantly share code, notes, and snippets.

@jlprat
Created October 17, 2022 18:30
Show Gist options
  • Save jlprat/848971863fa3dfb2c31f0e78a991eeb6 to your computer and use it in GitHub Desktop.
Save jlprat/848971863fa3dfb2c31f0e78a991eeb6 to your computer and use it in GitHub Desktop.
ffmpeg cookbook

Change format of video

ffmpeg -i source.webm target.mov

Change length of video

This gets the first 10 seconds of the video

ffmpeg -i source.mov -ss 00:00:00 -t 00:00:10 target.mov

Add watermarks

Add a 200px watermark on the top right (20p x 10p margin)

ffmpeg -i source.mov -i watermark.png -filter_complex "overlay=W-220:10" output.mov

Add a 200px watermark on the top left (10p x 10p margin)

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" output.mp4

Make a png file smaller (in pixels)

convert watermark.png -resize 200x200 watermark-small.png

Zoom 20%

From center-top

ffmpeg -i input.mov -vf "zoompan=z=1.2 :d=1 :x='iw/2 - (iw/1.2/2)'" output.mov

From top-left

ffmpeg -i input.mov -vf "zoompan=z=1.2 :d=1" output.mov

Zoom panning to top left

First we scale it up 10 times, then we increase the zoom 0.003 per second, scale back to original.

 ffmpeg -i input.mp4 -vf scale=12800x7200,zoompan=z=pzoom+0.003:d=1:s=1280x720:fps=30 output02.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment