Introduction: Movie Still Photo Frame (vid2frame)
Repurpose an old digital photo frame to display stills from your favorite movies or YouTube videos. The demo video was sped up to better show how it changes between the frames.
Digital photo frames were all the rage in the mid-2000s. They seemed to have fallen out of favor now that there is much smarter, more-multipurpose tech. Due to their ubiquity, they seem to be a dime a dozen now. I frequently comb through the computer/tech sections of thrift stores to see what oddities I can find for projects. At almost any thrift store, you can easily find these digital photo frames for just a few bucks.
I decided to use these photo frames to display stills from movies. I wrote code to split movies into individual frames and show the frames at a very slow rate. The goal is not to watch the movie at a slow speed, but to have beautiful static images that change every 5-10 seconds. It's interesting to walk by the photo frame and see a unique point in a movie. The ever-changing photo frame has the knack of pulling you into the moment as you realize the change and reminisce on the scene in the movie.
This idea was inspired by Douglas Gordon's art installation "24-Hour Psycho" that I read about in Don Delillo's Point Omega. Douglas Gordon slowed down Hitchcock's Psycho to have a run time of 24 hours and projected it onto a translucent screen.
The code was made to run in Google Colaboratory to allow for quicker video editing. The vid2frame Colab Notebook can be found at the following link: https://colab.research.google.com/drive/1YG-Y6ejeqiEQlD2plnu6FP96pQEvQg3Q?usp=sharing
Step 1: Vid2frame Overview
Intro to Colab
Google Colaboratory is a Python development environment using Jupyter Notebooks that allows you to connect to Google’s powerful cloud computing resources and run Python code. It allows you to maintain a runtime environment where you can install packages, access data online, navigate a file system, and store/reuse data.
The vid2frame program relies on a lot of video/image processing which can be rather intensive. Using the free cloud-computing resource will help you avoid burdening your own processor.
Executing Code in Colab
There are two different types of cells: code & text. Text cells are used to describe what's going on. Code cells can be executed one at a time by clicking the play button.
vid2frame Google Colab Notebook: https://colab.research.google.com/drive/1YG-Y6ejeqiEQlD2plnu6FP96pQEvQg3Q?usp=sharing
This program will take a video file from Google Drive, Google Colab, or directly from YouTube as its source. It will then output a series of images compressed into a zip file. The Colab notebook is broken up into the following steps:
0. Set Parameters
1. Install Dependencies
2. Mount Google Drive
3. Download YouTube Video
4. Split Video into Frames
5. Frame Editing Parameters
6. Reorganize files
7. Zip Images
8. Download Output
Step 2: Set Parameters / Install Dependencies
You need to configure the settings for your specific configuration based on the input and output format. First, you need to select your input source: Google Drive, Google Colab, or YouTube. If you uploaded the file to Google Drive or Google Colab, you will need to specify the filename. If you selected YouTube, you will need to enter the URL. Finally, you will need to specify the resolution of your digital photo frame in pixels.
Google Colab has a lot of common libraries and programs installed by default. The only dependency we will need to install is yt-dlp if you selected YouTube as your source. yt-dlp is a youtube-dl fork with additional features and fixes.
Step 3: Mount Google Drive or Download YouTube
Mount Google Drive
The Mount Google Drive cell only runs if you selected Google Drive as your input or output. Mounting Google Drive requires authentication. Once you run the cell, a series of windows will pop up asking you to authorize access. Follow the instructions. It mounts your Drive at /content/drive/MyDrive. I created a folder called vid2frame for use with the project.
Download YouTube Video
The Download YouTube Video cell only runs if you selected Youtube as your input. The program downloads YouTube video using yt-dlp (youtube-dl fork). It first searches through all the sources to find the best source based upon the photo frame resolution while also taking into consideration what video codecs ffmpeg can handle by default. After it finds the best source, it begins to download the file to the Colab cloud computing resource.
Step 4: Split Video Into Frames
Once the input source is finally ready, it is time to split the video up frame by frame. It does this using the program ffmpeg which is run with a subprocess call from Python. The reason we call ffmpeg from Python instead of running it on its own is that we need to know how many images there will be. We retrieve the number of frames in the video using ffprobe. Then we can determine how many images there will need to be and how many leading zeros need to be in the filename to maintain the order of the frames. It stores the images in a directory called images.
Step 5: Editing Frames
Next, we need to determine if and how we will edit the frames. There are many different ways to edit the images. I have provided three examples: delete every nth frame, center crop, and black and white. Select the parameters in the Colab form to determine how you want to edit the images.
Delete Every Nth Frame
Choose this option if the total size of the images is too large or you want it to play a little "faster". It will delete every nth frame where n is a value that you specify. Specify zero if you don't want to remove any frames.
Choose this option if you want a "full screen" effect. It will crop the images to fit your display; however, you will likely lose some of the image depending upon the original size of the video.
Convert to Black & White
Choose this option if you want to convert the images to black and white. If you want to apply filters to the images, you can do so here. Just modify the code in the cell.
Step 6: Reorganize and Zip Files
Through this project, I learned something new about storing files. When formatting and copying files to the SD card for my photo frame, I found that you could not have more than 2^16 or 65,356 files in a folder. In order to avoid this issue, this cell is responsible for reorganizing the images to avoid hitting this limit. The folders are sequentially numbers to ensure the frames of the video will still be played in order despite being in different folders.
Step 7: Download Output
Either downloads the zip file from Colab directly or moves the zip file to Google Drive. Downloading to Google Drive requires authentication and a secondary step of downloading the zip file from Google Drive; however, it is typically much faster. Downloading directly from Colab is more straightforward, but much slower.
Step 8: Display!
Unzip the file and copy the files to a media of your choice that your digital photo frame supports. I copied my files to an SD card for my photo frame. Plug it in and test it out! Once it is working, set the speed to something that looks good to you and mount it on the wall. Now, sit back and relax! Try it with your favorite movies. The more visually striking, the better!
Step 9: More Projects
Participated in the
Trash to Treasure Contest