# Movie Barcodes

I loved the Moviebarcode site that I found via MetaFilter and wanted to create some bar­codes of my own. After a bit of fid­dling I managed to produce some reas­on­able fac­sim­iles using a com­bin­a­tion of VLC and ImageMagick.

This example barcode is from Sleep Dealer.

I used VLC under Windows 7 and ImageMagick under Ubuntu Linux because that’s where they were already installed, but I imagine the com­mands are pretty similar irre­spective of which OS you are using.

Step 1 — Extract images

vlc movie.avi --video-filter=scene --scene-prefix=movie --scene-ratio=90 --scene-path=c:\movie

The important option is scene-ratio which tells VLC how many frames to capture. A value of 90 cap­tures every ninetieth frame and will create about two thou­sand images for a two hour film; VLC creates .png files by default but you can force it to create JPEGs by adding --scene-format=jpg. The scene-path command tells VLC where to store the images; if you omit this option it uses the default folder (My Pictures in Windows).

This step does require VLC to play the whole movie at normal speed, but muting the sound and leaving it running in the back­ground isn’t a problem.

Step 2 — Resize images

To create the barcode each frame needs to be reduced to one pixel wide using ImageMagick. You can do this in two ways: res­izing or crop­ping. Resizing gives a better “average” of the frame but crop­ping gives a sharper image. These com­mands also convert the .png files to .jpg files which helps to save disk space.

convert *.png -resize 1x{screenshot height}\! movie.jpg

convert *.png -crop 1x{screenshot height}+X+Y movie.jpg

The \! option pre­vents ImageMagick from pre­serving the aspect ratio of the ori­ginal image when res­izing and the +X and +Y options tell ImageMagick where in the image to crop; you prob­ably want to select X to be halfway across your image and Y to be zero. In both cases you’ll need to replace {screenshot height} with whatever the size of your ori­ginal screen­shots is.

Step 3 — Assemble barcode

Using ImageMagick:

montage -geometry +0+0 -tile x1 *.jpg barcode.png

The -geometry +0+0 command ensures that there is no border between images and the -tile x1 option tells ImageMagick to create a montage that is only one image high, i.e. one long stream. You need to be careful with how your files are numbered before this stage because ImageMagick works alpha­bet­ic­ally and will add image100.jpg before image20.jpg.

Step 4 (optional) — Smooth barcode

If you want a smoother result you can shrink the barcode down to one pixel high and then expand it back out to your desired size. Shrinking finds the average colour and when expanding back out the you get a smooth result con­taining only the aver­aged colour.

Smoothed version of the example Sleep Dealer barcode.

If you have any prob­lems, ques­tions or hints, or if you want me to produce a movie barcode for you, post in the com­ments below.

### 49 Responses to Movie Barcodes

1. Nick says:

Thanks for fig­uring this out, it’s fun!

Just wanted to let you know that there’s a much faster way of doing the first step if you have access to mplayer. You can do:
 mplayer -framedrop -speed 100 -vf framestep=90 -nosound -vo jpeg movie.avi 

Where, as above, -framestep=90 means extract every 90th frame. the -vo jpeg writes things out as jpegs (you can do -vo png if you want, but since we’re going to jpeg later anyway it’s mostly a waste of space).

The -speed 100 tells mplayer to try and play back at 100 times the standard speed. my com­puter couldn’t quite go that fast, but it did manage to do an hour of 1280×720 video in about 15 minutes, so that’s cer­tainly an improve­ment. the -framedrop and -nosound are just optim­iz­a­tions, which are not tech­nic­ally needed but will prob­ably make things go a bit faster.

Finally, here’s a barcode I made of episode 1 of Carnivale. It looks about as I expected.

2. Pingback: .musslautsein › Barcodes aus Filmen

3. Pingback: Distilling the atmosphere of movies

4. Pingback: I made my own movie bar code

5. Harm says:

I ripped more than 11.000 frames from the movie Amelie. Now I want to combine those through Image-Magick. Problem is that IM save everything into memory before out­put­ting. My whole com­puter holds at that moment. Using more than 16Gigs of RAM. Is there a way to let image magick do the res­izing frame by frame?

6. Mr Reid says:

Could you rename a thou­sand at a time, and process each as a batch? 11000 frames is a lot of images though — do you really need that many?

7. sol says:

how do you do step 1? can anyone guide me through the process? I don’t know how to work around these command lines. I’m using VLC, windows 7

8. Mr Reid says:

To be bru­tally honest, if you’re not happy working with the command line, then this process is prob­ably not for you. :(

I used Windows 7 and Ubuntu because that’s where the soft­ware was installed; it is pos­sible to do the entire process under Windows if you want.

9. sol says:

Yes this is new to me. :| But I think this movie barcode is a pretty neat project and I would love to try it. thanks for the reply!

10. Mr Reid says:

What movie are you trying to barcode?

11. sol says:

I’m trying to barcode pulp fiction, and maybe schindler’s list. Anyway, I finally managed to get Step 1 done. phew

12. josh says:

curious, how did you set it to name your files? even if i add a few digit padding, it seems to jumble the images in the final montage. Thoughts?
thanks~

13. Mr Reid says:

I used a sep­arate utility for ensuring that the files had the correct filenames.

14. josh says:

Or, you could use this process, worked great for me:

montage -geometry +0+0 -tile x1 'ls -1rtc NAME*.jpg |xargs' NAME.png

which lists the files in the correct order.

15. sol says:

So this is my first try. I used CS5 and picture merger genius to make this.

http://solblurgh.tumblr.com/post/5033738922/i-tried-making-my-own-movie-barcode-its-not-as

16. Astrakan says:

What utility did you use to make sure the file had the correct file names? And what logic did you use in naming them? Leading zeroes? Thanks.

17. Mr Reid says:

I used Métamorphose to rename files (sorting by modi­fic­a­tion date/time) and did use leading zeros to make sure that they’d be sorted into the right order.

18. Astrakan says:

I tried to do the exact same thing, but using a program called File Renamer, and run into the problem that hun­dreds of files were last mod­i­fied at the exact same time down to the second.

Is it perhaps because I’m in Windows? Does Linux use a more precise timestamp? I’m going to have a look at Métamorphose and see if perhaps the problem lies with File Renamer.

Thanks.

19. Astrakan says:

Yup. It works great using Métamorphose.

Thanks!

Hey, is there any chance of you cre­ating a barcode of “The Picture of Dorian Gray”? I’m not really pro­fi­cient at com­puting but I would appre­ciate the barcode very, very much.

21. Piotao says:

Hey, thank you for the idea. I’ve write small perl program to sim­plify the whole process. Only mplayer and ImageMagick is needed, and the process is very simple: run perl script and give to movie file. You got in a few minutes barcode.png file from the whole movie! The script is free, I’ve put it on my page, but I would like to say THANK YOU. I’ve linked to this page as a source of inform­a­tion, and you can take my script ;)
This is a link to script and this is a link to page with the inform­a­tion.
The script is able to convert HUGE amount of frames and memory error is fixed — instead of con­verting all files at once, I’ve decided to convert them one by one. This takes longer time, but your convert process will never be killed. On my PC with 8GB ram it is likely to be killed even for 1500 frames. So, here it is! Thank you for the whole blog, it is VERY inter­esting. Keep up the good work! I like it!

22. Alexandria says:

Hey, I’d love if you could make one for me if your still doing that just email me if you would, thanks. — Alex

23. Mr Reid says:

I’ve e-mailed you.

24. Hi,
I’m only vaguely familiar with the command line code– I tend to fall down if it’s not matlab! I run a mac and was curious how (if you knew) to use the ter­minal to execute such com­mands, if indeed that is the process to do it. And is ImageMagick neces­sary?
Thanks,

Andy

Also– love your site. I’ve referred a few people to the nuclear section!

25. Mr Reid says:

I’m glad you like this site.

I’m afraid I’m not a Mac person; I have no idea how they work and there­fore no idea if you can use the ter­minal; I’m sure there’s a way to do it without ImageMagick but I don’t know how that would work — perhaps some sort of scripting plugin for PhotoShop etc. I think you’ll need to find your­self a Mac expert.

26. I’ve sorted it, well, the majority! I’ve managed to make a barcode after fig­uring out how to install ImageMagick, and I’ve now got the hang of Terminal. Just took some googling. Just going to try the smoothing method now.

27. Maligned Arts says:

All I have to recom­mend is repla­cing ImageMa­gick ‘convert’ with ‘mogrify.’ Retains the same options — mogrify simply mod­i­fies the files in place, rather than cre­ating new. The benefit is fewer files to delete after com­pleting the montage operation.

Experimenting with alternate com­mands to capture frames — none of which proved superior to Nick’s in the first comment above — I hit upon a command line that provides an audio com­pli­ment to a movie barcode:

mplayer -sstep 5 -vc null -vo null -ao pcm:waveheader movie.avi

This results in a default file named audiodump.wav con­sisting of split second bursts of the movie’s audio track at five second inter­vals (the latter mod­i­fied by the value of the –sstep option). Equalization to cut off fre­quen­cies above 6000 Hz helps reduce clicks.

It’s fas­cin­ating the extent to which the source remains recog­niz­able. I’ll leave it to readers to discern for them­selves the cinema classic put through the shredder to yield this example.

28. Kristin says:

Hey,

Nice post, but I’m not sure I under­stand this at all. Is there a how to make these for Dummies link? Anything more simpler on where and how exactly to start? Not sure I’m familiar with all the com­mands or how they are being used. Any info would help!

29. Mr Reid says:

If you’re not familiar with using the command line then this process prob­ably isn’t for you; the instruc­tions I’ve provided are about as for Dummies as I can get. Maybe someone else can offer better instruc­tions? What movie are you trying to barcode?

30. Rook says:

Great write up!

One ques­tion, optional step 4 says you can shrink to 1px high to get an average of the colors to smooth. Is this a command I change in step 3 or do I use GIMP to do this?

If I need to change the command what would it be changed to?

Thanks again.

31. Mr Reid says:

I would do this with standard image-editing soft­ware like GIMP or PhotoShop.

32. ElZee says:

I have tried for days to get this to work and I just can’t seem to make it right. I have all the frames reduced to slivers but I can’t get them together. Could I e-mail the frames to you and would you put them together for me and send the result back? I would really appre­ciate it.

33. Mr Reid says:

Which film are you trying to barcode?

34. ElZee says:

An old Irish anim­ated film called Charlie. I can host the images on a third party website instead of having to send a large, slow e-mail attach­ment for you.

35. ElZee says:

So can you help me out?

36. Ali Reid says:

Hi there
I’ve enjoyed going through your method. I guess I have mixed ability.
The imagema­gick command doesn’t work for me and i’m not sure how to troubleshoot.
i am on win7, and i installed imagema­gick. Here’s my command and error:

convert *.png –resize 1x{288}\! movie.jpg
convert.exe: invalid argu­ment for option ‘-resize’: 1x{288}\! @ error/convert.c/
ConvertImageCommand/2355.

help!

37. Ali Reid says:

nvm.
had to drop the \ for the crop command. and the squiggley brackets.
thanks!

38. Ben M says:

Hey Mr. Reid!

Any chance you could barcode “Grease” for a late christmas gift for my aunt?

Thanks!
Ben

39. Pingback: MOVIEBARCODE | whatleydude

40. Spence says:

Thanks for the guide, I tried it out for a com­puter game and it worked quite well. http://adensepencil.wordpress.com/2012/05/18/gamebarcode-tutorial/