Last active
July 8, 2017 13:21
-
-
Save scturtle/15685020c01e4c5a8072 to your computer and use it in GitHub Desktop.
ffmpeg cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://support.twitter.com/articles/20172128?lang=en#video-formats | |
# https://trac.ffmpeg.org/wiki/Encode/H.264 | |
# gif to mp4 for twitter | |
ffmpeg -i in.gif -pix_fmt yuv420p -vf crop="floor(in_w/2)*2:floor(in_h/2)*2" out.mp4 | |
# extract part of video (-t duration) | |
ffmpeg -i in.mp4 -ss 00:00:00.000 -to 00:00:15.000 -vcodec copy -acodec copy part.mp4 | |
# convert to mp4 for twitter | |
ffmpeg -i in.mp4 -vcodec libx264 -acodec aac -strict experimental out.mp4 | |
# H.264 profile: -profile:v baseline/main/high/high10/high422/high444 | |
# preset: -preset ultrafast/superfast/veryfast/faster/fast/[medium]/slow/slower/veryslow | |
# bitrate = file size / duration: -b:v 555k -b:a 128k | |
# minrate/maxrate: -minrate 1024k -maxrate 1024k | |
# -vf scale=-1:480 | |
# to gif (two steps) | |
ffmpeg -i part.mp4 -vf fps=15,scale=640:-1:flags=lanczos,palettegen -y /tmp/palette.png | |
ffmpeg -i part.mp4 -i /tmp/palette.png -lavfi 'fps=15,scale=640:-1:flags=lanczos [x]; [x][1:v] paletteuse' -y part.gif | |
# add empty voice track and limit the frame rate | |
ffmpeg -f lavfi -i anullsrc -i in.mov -r 40 -preset slower -shortest -c:a aac -strict experimental out.mov |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment