Movie Barcodes

I loved the Moviebarcode site that I found via Meta­Filter and wanted to create some barcodes of my own. After a bit of fiddling I managed to produce some reas­on­able fac­sim­iles using a com­bin­a­tion of VLC and ImageMa­gick.

This example barcode is from Sleep Dealer.

I used VLC under Windows 7 and ImageMa­gick under Ubuntu Linux because that’s where they were already installed, but I imagine the commands 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 captures every ninetieth frame and will create about two thousand 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 ImageMa­gick. You can do this in two ways: resizing or cropping. Resizing gives a better “average” of the frame but cropping gives a sharper image. These commands 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 prevents ImageMa­gick from pre­serving the aspect ratio of the original image when resizing and the +X and +Y options tell ImageMa­gick where in the image to crop; you probably 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 original screen­shots is.

Step 3 — Assemble barcode

Using ImageMa­gick:

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 ImageMa­gick 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 ImageMa­gick 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 averaged colour.

Smoothed version of the example Sleep Dealer barcode.

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


43 Responses to Movie Barcodes

  1. Nick says:

    Thanks for figuring 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 computer 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 probably make things go a bit faster.

    Finally, here’s a barcode I made of episode 1 of Car­ni­vale. It looks about as I expected.

  2. Pingback: The Oscar Movies Barcode’d : misterhonk.de

  3. Pingback: Blog Of The Day: Moviebarcode | Kotzendes Einhorn

  4. Pingback: .musslautsein › Barcodes aus Filmen

  5. Pingback: Distilling the atmosphere of movies

  6. Pingback: I made my own movie bar code

  7. 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 computer holds at that moment. Using more than 16Gigs of RAM. Is there a way to let image magick do the resizing frame by frame?

  8. Mr Reid says:

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

  9. Pingback: Something new, the MovieBarCode | MenReport

  10. Pingback: Kunst- und Webtipp: Moviebarcode | Clothes & Cakes

  11. 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

  12. Mr Reid says:

    To be brutally honest, if you’re not happy working with the command line, then this process is probably not for you. :(

    I used Windows 7 and Ubuntu because that’s where the software was installed; it is possible to do the entire process under Windows if you want.

  13. 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!

  14. Mr Reid says:

    What movie are you trying to barcode?

  15. sol says:

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

  16. 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~

  17. Mr Reid says:

    I used a separate utility for ensuring that the files had the correct filenames.

  18. 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.

  19. 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

  20. 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.

  21. Mr Reid says:

    I used Méta­morphose 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.

  22. Astrakan says:

    I tried to do the exact same thing, but using a program called File Renamer, and run into the problem that hundreds of files were last modified 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éta­morphose and see if perhaps the problem lies with File Renamer.

    Thanks.

  23. Astrakan says:

    Yup. It works great using Métamorphose.

    Thanks!

  24. Konrad says:

    Hey, is there any chance of you creating 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.

  25. Pingback: Movie Barcode: How-To e Shop | Lega Nerd

  26. Piotao says:

    Hey, thank you for the idea. I’ve write small perl program to simplify the whole process. Only mplayer and ImageMa­gick 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!

  27. 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

  28. Mr Reid says:

    I’ve e-mailed you.

  29. 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 terminal to execute such commands, if indeed that is the process to do it. And is ImageMa­gick neces­sary?
    Thanks,

    Andy

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

  30. 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 terminal; I’m sure there’s a way to do it without ImageMa­gick but I don’t know how that would work — perhaps some sort of scripting plugin for Pho­toShop etc. I think you’ll need to find yourself a Mac expert.

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

  32. Maligned Arts says:

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

    Exper­i­menting with alternate commands 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 modified by the value of the –sstep option). Equal­iz­a­tion 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.

  33. 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 commands or how they are being used. Any info would help!

  34. Mr Reid says:

    If you’re not familiar with using the command line then this process probably 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?

  35. Rook says:

    Great write up!

    One question, 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.

  36. Mr Reid says:

    I would do this with standard image-editing software like GIMP or PhotoShop.

  37. 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.

  38. Mr Reid says:

    Which film are you trying to barcode?

  39. ElZee says:

    An old Irish animated 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.

  40. ElZee says:

    So can you help me out?

  41. 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 argument for option ‘-resize’: 1x{288}\! @ error/convert.c/
    ConvertImageCommand/2355.

    help!

  42. Ali Reid says:

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

  43. Ben M says:

    Hey Mr. Reid!

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

    Thanks!
    Ben

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>