Updated: August 23, 2024
Several weeks ago, I told you about the "can't send video" problem in WhatsApp. You wanna share dank memes with your buddies, and technology be standin' in your way, fam, fr. Well, in that guide, I explained how you can work around the issue - by sending HD videos, duh. But then, if you only have SD quality content, what can you do? On the phone, it ain't trivial, but on the desktop, you have a range of options.
In today's wee tutorial, I will revisit an old and powerful media editing tool - ffmpeg, your one-stop shop for everything audio or video. This program lets you manipulate media files any which you want - convert among many different formats, split and join clips, scale, extract individual frames, add subtitles, change playback speed, and so much more. Well, let's talk about converting video into animated images, GIFs.
Why would you want to do this?
Well, as I mentioned before, you might have a problem sharing video content with your friends, for whatever technological limitation in whatever program or app. In some scenarios, you may only be interested in the actual video part (no audio), and you may also face space/size restrictions or format restrictions. You may also want to embed clips in the chat, rather than offer them as downloadable files, as the former offers a more streamlined meme experience.
This led me onto a quest to see what I can do with video clips. Well, if you have SD content, you can still transcode it as HD. No problem. Similarly, you can convert video clips into GIF images. However, by default, such a conversion may not be pretty, and you could end up with low-res, non-looping files. This goes against the creed of respectable memeology.
Well, let's proceed then and convert videos files (say MP4, MOV) into GIFs ...
Ffmeg command line
The "easiest" way to do this, without online portals or downloading all sorts of weird apps to your phone, is to use the free, open-source ffmpeg utility (on the desktop). If you're a Linux user, it's available for installation straight from the repos. Windows users can just download the relevant executables from the official site, and go from there.
ffmpeg -i [input] -vf "fps=XX,scale=YYYY:-1:flags=lanczos" -loop 0 [output]
A more specific example:
ffmpeg -i Test.mov -vf "fps=24,scale=1920:-1:flags=lanczos" -loop 0 Test.gif
What do we have here?
- -i provides the name of the input file, the video we want to convert.
- -vf specifies the video options we want to use for the conversion
- fps=XX defines the frame rate; try to match this to the original video frame rate, to avoid any frame drops or interpolation. Thus, if you have a normal 24FPS video, then you'd use 24. You don't have to, though, but this may result in the actual GIF playback being slower or faster than the original (unless you provide a different frame transition speed).
- scale=YYYY:-1 allows you to scale up/down the video, which also allows us to create HD content. You can provide both height and width, or you can only provide one, and allow ffmpeg to scale the other proportionally (-1). In my example, I am converting a video to an HD GIF with a 1920px width. The height will match the original video proportions, so if you recorded it with say 16:9 ratio, then the height will be set to 1080 px. Or you can do the other way around. Please note you can (and should usually) use much smaller dimensions, like 320 px or 640 px. We will see why very shortly. Anyway, you can also try something like:
scale=1920:1080
scale=-1:640
- flags defines the algorithm used for scaling (much as you'd do in say GIMP). There's a lot more you can do here, including the manipulation of color channels and whatnot, but for all practical purposes, the defaults will be good enough. You can try lanczos, neighbor, bicubic, etc.
- -loop 0 tells ffmpeg to create an infinitely looping GIF.
- Lastly, we have the output name.
Let ffmpeg run, and job done. Some thumbnails, at your pleasure. Now, they don't really show the full extent of the "action", either video or GIF, but there's a big reason for that.
The reason? File size. My original video is a 5-sec clip, and it weighs 3.5 MB. The GIF weights 61.5 MB! I tried with a different clip, and there, the differences were slightly less cardinal, 86 vs 152 MB, but it all depends on the amount of information in the clip. To that end, I didn't add the actual artifacts here, as they would hog the bandwidth all too easily. Hint: there are ways around it, but we shall talk about that separately.
But there, we did it. Job done, memeification complete.
Conclusion
Ffmeg is a frighteningly complex and useful tool. With some 5,000 flags and options, give or take, you really can do anything and everything possible. You just need patience and tenancy, but when it comes to doing something with video or audio, look no farther. That's it. Today, we needed to make sweet GIFs, and there you have it.
The suggestions outlined above should help you become a more respectable memeista. This should also help you create high-quality content. The conversion principles are the same, regardless of the input and output formats, so if you need to make HD video out of SD video (so to speak), you can. I thought GIFs would be an even more avantgarde option. Well, for what it's worth, hopefully this was useful. Now ere we disperse, we shall have ANOTHER article on GIF memeing, and it will cover all the different methods on creating gif files, their advantages and such. Soon, soon. Dank away.
Cheers.