menga.net
home books search contact

***Secret FSR Fender guitars? Yes, they exist, and they're right here

As an Amazon Associate I earn from qualifying purchases. (What does this mean?)

how to make a precise GIF animation loop from a video clip

Yeah, I still do this because it's fun. However, I've changed the way I go about it so I can get ultra precise loops.

There are only two tools required to do this, mpv media player and FFmpeg. And yes, we will have to go to the scary command line to make this work correctly. When you want precise loops, that's what you have to do.

For this example I will be using a clip from a vintage television commercial for the Gillette Super Speed safety razor.

Side note: For those that use a safety razor such as I do, you don't need a vintage Gillette as there are plenty made new today. Get a razor, get some blades, shave happy.

The three features I use from mpv to get exactly what I want for my GIF animation loop is a) showing the exact timestamp, b) the comma key to go back 1 frame, and c) the period key to go forward one frame.

When playing the video using mpv, I get to the point where I want to start my loop, press spacebar to stop the video, take the mouse, hover over the bottom left area and left-click the time one so it shows milliseconds. I can keep the time displaying while stopped just by leaving my mouse cursor hovering there.

image

After that, I go forward/backward frames using the comma and period keys until I get the precise starting time I want.

This is when I bring up a command line and start using FFmpeg.

In FFmpeg, the start point is defined with ss and end point with to. However, a little more needs to be done because I need to reduce the dimensions framerate to get the file size down. I usually specify 8 frames per second as that seems to work best for most clips. The original video is 320x240 but I shrink this to 200.

The whole thing looks like this after I have the start and end times I want:

ffmpeg -i video.mp4 -ss 00:00:33.800 -to 00:00:36.200 -vf scale=200:-2,fps=8 animation.gif

This is what all the above means:

FFmpeg with input file video.mp4, starting at timestamp 00:00:33.800, ending at 00:00:36.200, scale down to 200 pixels wide and auto-calculate the height, framerate of 8fps, write to file animation.gif.

Now I have this:

image

Job done. I'm a happy camper.

Published 2024 Jun 4

image
Best ZOOM R8 tutorial book
highly rated, get recording quick!

Other things to check out