-
-
Save jsscclr/4878254c29fc6651ca9d16d37111b8bb to your computer and use it in GitHub Desktop.
A working cheat sheet for ffmpeg
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
#use case: converting image sequence to .mp4 video | |
#official documentation: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images | |
#description: | |
# An image sequence follows the pattern, defaultCanvas0-000000000.png (9 zeros) | |
# video codec is libx264 | |
# pixel format yuv420p | |
# output file is named out.mp4 | |
ffmpeg -i 'defaultCanvas0-%9d.png' -c:v libx264 -pix_fmt yuv420p out.mp4 | |
#if you want your image sequence to start on a different number than index 0, use the -start_number parameter | |
ffmpeg -start_number 000000060 -i 'defaultCanvas-%9d.png' -c:v libx264 -pix_fmt yuv420p out.mp4 | |
#description: | |
#if you want to use ffmpeg to generate an animated gif from an image sequence | |
# -vf : video filter | |
#scale=[pixels] : -1 scale the frame and preserve aspect ratio. In this case we are scaling the width to 500px | |
# if you want to scale the height and preserve aspect ratio, scale=-1:500 | |
ffmpeg -start_number 000000090 -i 'defaultCanvas0-%9d.png' -vf scale=500:-1 out.gif | |
#more info on high quality gifs with ffmpeg | |
#http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
#another helpful tool for creating animated gifs with frame control is imageMagick: | |
#http://www.imagemagick.org/script/command-line-tools.php | |
# Making an Image Sequence from a video - from https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence | |
ffmpeg -i video.webm image-%03d.png | |
#This will extract 25 images per second from the file video.webm and save them as image-000.png, image-001.png, image-002.png up to image-999.png. If there are more than 1000 frames then he last image will be overwritten with the remaining frames leaving only the last frame. | |
#The encoding of the images and of the video is inferred from the extensions. The framerate is 25 fps by default. The images width and height is taken from the video. | |
#Extract one image per second: | |
ffmpeg -i video.webm -vf fps=1 image-%03d.png | |
#Extract one image from a specific time: | |
ffmpeg -i video.webm -ss 00:00:10 -vframes 1 thumbnail.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment