Creating GIF using FFMPEG - using images

Apr 22, 2020 01:01

Another steps discovered...

1st step: Cut the video to the scene where you want it to be GIF'ed
ffmpeg -i input.mkv -an -ss hh:mm:ss.000 -to hh:mm:ss.000 -qscale 0 output.mkv
* -an : remove audio stream
* -ss : video start time
* -to : video end time
* -qscale 0 : I always use this command to retain the original quality of the source used on the output.

2nd step: Filter out color palette to be used when creating the GIF
ffmpeg -i input.mkv -vf palettegen p.png

3rd step: Extract images from the cut video
ffmpeg -i input.mkv -qscale 0 image%2d.jpg
* a bunch of images extracted from the cut video will be renamed as follow: image01.jpg, image.02.jpg etc

4th step: Resize the bunch of images
ffmpeg -i image%2d.jpg -vf scale=480:-1 -qscale 0 pic%d.jpg
* image01.jpg, image02.jpg etc will be resize to resolution 480xY and rename to pic1.jpg, pic2.jpg etc

5th step: Creating the GIF
ffmpeg -f image2 -framerate 20 -i pic%d.jpg -i p.png -lavfi paletteuse out.gif
* set the framerate according to fast or slow the GIF you want it to be.

Walla!~

ffmpeg: gif

Previous post Next post
Up