How I Made My Own Left Shark GIFs With ffmpeg

How I Made My Own Left Shark GIFs With ffmpeg

Tutorials ffmpeg gifs internet-culture tutorial

I didn't actually watch most of the Super Bowl on Sunday. I had it on in the background while I was doing dishes, half paying attention, and then my phone started buzzing nonstop around halftime. Everyone was talking about a shark. Not the game, not Katy Perry's actual singing, a backup dancer in a shark costume who was very clearly not following the choreography.

By the time I dried my hands and checked Twitter, "Left Shark" was already a full blown thing. Within maybe twenty minutes there were fan cams, slow-mo clips, and a dozen different GIFs floating around my timeline, some good, most kind of janky and pixelated. That got me thinking about how bad most of the GIFs I was seeing actually were, so I decided to make my own and figure out the right way to do it instead of just screen-recording my monitor like a caveman, which is apparently what a lot of people were doing last night.

Skip Photoshop, use ffmpeg

I used to make GIFs in Photoshop, importing a video as frames and using Save for Web, and it works but it's slow and the file sizes it spits out are kind of embarrassing. ffmpeg does the same job from the command line in about two seconds once you've got the syntax down. Here's roughly what I ran on the clip I'd saved off a recording:

ffmpeg -i leftshark.mp4 -ss 00:00:08 -t 00:00:03 -vf "fps=15,scale=480:-1" leftshark.gif

Breaking that down: -ss sets where in the clip you start, -t is how long the clip runs, and the -vf bit is your filter chain, dropping the frame rate to 15fps and scaling the width down to 480px so the file doesn't balloon. Full frame rate video turned into a GIF at full resolution will choke browsers and chew through your data plan for no reason. Most GIFs on the internet do not need to be more than a few hundred pixels wide.

The output from that one command was already smaller and cleaner than anything I'd gotten out of Photoshop in five times the effort. I ran it maybe six or seven times, nudging the start time by a second on each try, until I had the exact three seconds where the shark just kind of gives up and starts doing its own thing off to the side.

A small complaint about Tumblr

I tried uploading the finished GIF to Tumblr and it got compressed into mush, colors banding all over the place, because their size limits are still stuck in some earlier era of the internet. Twitter handled it fine since they've had native GIF support in tweets for a while now, so that's where I actually posted it, and it did okay, a few dozen retweets and replies from people who follow this blog. Nothing wild. Which is honestly fine by me.

Here's my actual opinion on the whole thing, since apparently everybody has one today: the right shark, the one nailing every move like it's being graded, is way funnier than left shark. Left shark gets all the attention because it's the "relatable" one, doing its own thing, not really trying. But the right shark committing so hard to full choreography right next to a shark that's clearly given up is the better joke. Nobody's making GIFs of that one though.

Anyway, if you want to make your own reaction GIFs instead of grabbing whatever's already floating around Imgur, ffmpeg is worth the twenty minutes it takes to learn the basic flags. You don't need any of the fancier color palette tricks people bring up for this kind of thing, plain scale and fps flags get you most of the way there for anything you're posting to Twitter or texting a friend. I'll probably do a longer post on ffmpeg basics at some point since I use it constantly for cropping and trimming clips and don't think I've properly written it up here yet.