Photoshop Fails, GIMP and the Console Save the Day

This is entirely unexpected. GIMP was just easier to use than Photoshop. Was it for some obscure and arcane task that someone had written a GIMP feature for? No. I was just making a GIF for an assignment.

An animated GIF of Samwell Tarly from Game of Thrones blinking created with ffmpeg and GIMP

This is the face I made when looking at photoshop’s video import functionality in CS6.

I tried to import  a scene ripped from handbrake into photoshop, but it didn’t recognize the format. Supposedly Photoshop CS6 is supposed to be good at this. It supposedly supports MPEG-4. My video reads as encoded in MPEG-4. Do I understand why it doesn’t work? No. Does photoshop have clear support for creating a GIF from a bunch of sequential images in the same way GIMP does? Also an apparent no. I don’t want to spend forever fiddling with programa and documentation things to find out how to make each of these tools do what I want. Instead, I’ll use simpler tools. I’ll use the terminal window.

Details after the break.

I used ffmpeg, a tool useful for decoding and encoding video and audio. I’m pretty sure there’s some sort of free GUI version of it, and I’ve heard rumors that a ton of paid software somehow uses it too. But I’m just going to use the command line instead. After noting down some interesting time ranges in VLC and bit of googling that showed me what other people had done in similar situations, I came up with the following ffmpeg command to turn some footage into the .jpgs that GIMP needs:

ffmpeg -i video_file.avi -ss 00:42:25 -t 3 -f image2 -vcodec mjpeg frames/samlook-%03d.jpg

And the translation for the everyday user:

ffmpeg -i video_file.avi

means “Hey ffmpeg, open that that file as the input.

-ss 00:42:25

means “start recording at 0 hours, 42 minutes, and 25 seconds into the file”.

-t 3

“means “record for 3 seconds”. And lastly,

-f image2 -vcodec mjpeg frames/samlook-%03d.jpg

means “convert every frame to a numbered image named samtarly-NUMBERHERE.jpg .

Here’s a templated version you can try if you ever want to install ffmpeg (linux users already probably have it installed).

ffmpeg -i video_file.avi -ss hours:minutes:seconds -t lengthToRecordInSecodns -f image2 -vcodec mjpeg whereToPutTheFiles-%03d.jpg

At this point, I had a ton of images, but then I had another problem:

one of the extra frames I picked up by accident

This guy. Nine frames of him to be exact.

I deleted the extra frames, but it looks like either ffmpeg is innaccurate or it’s something about the filetime I was importing from. Regardless of what caused it, I removed the extra files from the frames directory. Then I was left with another problem: ffmpeg expects filename sequences to start at zero. I could try to look up a command for it, but instead i’ll just rename all the files. That’s hard, right? Nope. On OSX and Linux, it’s pretty quick. Stack Overflow helps me out with a bash script to modify to rename my files:


find . -name '*.jpg' |
gawk 'BEGIN{ a=0 }{ printf "mv %s samblink-%03d.jpg\n", $0, a++}' |

I run it in my frames directory, and now mpeg is happy with the file names. I follow the ds106 wiki’s instructions except for one thing: the frame rate. By default, GIMP sets it to 10 frames per second. That won’t do. I have enough frames to play my gif back at the standard ~24 fps. So I need to calculate a new frame delay. And then something magical happens. I have to round up to the nearest millisecond, and behold:

1000 ms / 23.976 frames == ~41.708 frames ~= 42 ms/frame.

A delay of 42 ms between frames. Douglas Adams would be proud.

My settings for export from GIMP to a gif for the tarly gif.

My settings for export from GIMP for the tarly gif.

I haven’t had to use the command line for anything this semester. I’m not sure whether I should be happy that I got a little bit of bash practice, or disappointed in Photoshop CS6.


3 thoughts on “Photoshop Fails, GIMP and the Console Save the Day

    • Thanks for the link. I chose ffmpeg over streamclip for a number of reasons:
      1) it works with just about any video format
      2) I’ve used it before to convert video between formats
      3) It’s is available on every OS that I use, including Linux

      Combined, those differences mean that I can use it to make gifs on any of the computers I own.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s