Making Video Into Barcode

It’s a video, in a single graphic.

Kaili Chen
Mar 12 · 2 min read
Generating a graphic from video frames, image by author

This project was inspired by a chance encounter on Reddit about “movie barcodes” and thought that it was pretty genius — a movie represented in what’s essentially a series of colored bars (more examples can be found here). I wanted to try making graphical barcodes on a smaller scale, of videos in a subsequent thought.

Making Barcodes

Overview of the process to make a barcode from a video, image by author

There are 3 steps in the process:

  1. Getting each frame from the video
  2. “Shrinking” each frame into bar
  3. Combining the bars to make the barcode

Preliminary Notes:

  • Code examples used in this writing can be found here
  • The video used in the examples is not on GitHub, you would have to find your own video file
  • For the sake of this example, I have a video file saved locally as “video.mp4” and the source is here

Step 1: Getting each frame from the video

This step uses cv2 to go through the video and capture each second as an image, or “frame” in a folder.

Step 2: “Shrinking” each frame into bar

That just refers to reducing (resizing) each frame’s width into a size that resembles a bar (narrow width, tall height). Interpolation is set to INTER_AREA, which according to cv2’s documentation is preferred for “image decimation”, or shrinking.

# reducing the size of image frame to a bar (1 x 920)bar_width = 1
barcode_height = 920
bar = cv2.resize(frame, (bar_width, barcode_height), interpolation = cv2.INTER_AREA)

Step 3: Combining the bars to make the barcode

After getting the bars, what’s left is to put them together. In the code snippet below, each frame (the result of step 1) is read, reduced to a bar, and added onto a blank image to make up a barcode in a loop.

Combining all the snippets:

The resulting barcode:

Image by author

It didn’t come out too bad.

Ideas for Further Development

The code is but a base version, other more interesting things can be built on it, such as:

  • Using the barcode as a background (e.g. for typography)
  • Using more or less frequent frame extraction intervals (e.g. getting each frame half a second / 5 second apart)
  • Changing how the bars look or lay (e.g. horizontally, at an angle, using circles, arcs)

Geek Culture

Proud to geek out.

Thanks to The Startup

Sign up for Geek Culture Hits

By Geek Culture

Subscribe to receive top 10 most read stories of Geek Culture — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Kaili Chen

Written by

Student of tech, working in tech.

Geek Culture

A new tech publication by Start it up (

Kaili Chen

Written by

Student of tech, working in tech.

Geek Culture

A new tech publication by Start it up (

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store