Skip to content

Instantly share code, notes, and snippets.

@keiranlovett
Created February 13, 2016 15:02
Show Gist options
  • Save keiranlovett/a0bcf0bdce754c8dc06c to your computer and use it in GitHub Desktop.
Save keiranlovett/a0bcf0bdce754c8dc06c to your computer and use it in GitHub Desktop.
FFMPEG Cheatsheet

Reduce a mp4 video to half size

fmpeg -ss 30 -i video-2015.mp4 -vf scale='iw/2':-1 -c:v libx264 -c:a libfdk_aac video-2015-opt.mp4

Convert mp4 to webm

`ffmpeg -i video.mp4 -c:v libvpx -b:v 1M -c:a libvorbis video.webm``

Convert mp4 to ogg

fmpeg -i video.mp4 -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 video.ogg

Resize video

ffmpeg -i input.mp4 -vf scale=-1:720 -c:v libx264 -crf 0 -preset veryslow -c:a copy output.mp4

convert to another format, resize withouth quality loss

ffmpeg -i vitrine.mp4 -vf scale=1024:-1 -q:vscale 0 vitrine.avi

Create high-quality animated gifs

ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif

Extract thumbnails

ffmpeg -i input.mp4 -f image2 -vf "fps=fps=1/5, scale=90:-1" thumb-%04d.jpg

Music from Video

ffmpeg -i input.mov music.mp3

Scale the resolution to a specific size:

ffmpeg -i input.mp4 -vcodec libx264 -s 1024x768 output.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment