Movie Barcodes

I loved the Moviebarcode site that I found via MetaFilter and wanted to create some barcodes of my own. After a bit of fiddling I managed to produce some reasonable facsimiles using a combination 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 commands are pretty similar irrespective 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 background 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: 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 ImageMagick from preserving the aspect ratio of the original image when resizing and the +X and +Y options tell ImageMagick 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 screenshots 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 alphabetically 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 containing only the averaged colour.

Smoothed version of the example Sleep Dealer barcode.

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

55 thoughts on “Movie Barcodes

  1. Hi! I am looking for someone that could make a moviebarcode of the prestige for me. I have been trying to make one myself but this has not worked out so far.. If someone could make that for me that would be a huge help!


  2. Hi,
    Do you still make moviebarcodes for other people? I would be so happy if you do! I hope to hear from you:)


Leave a Reply