Turning files into videos
I recently have seen a lot of videos on YouTube showing seemingly random static like videos. Here is an example of one of them:
WARNING: This video contains flashing lights and is quite loud.
I was curious about how these videos were made and I found out a way to make them using Python and ffmpeg.
How to make these videos
To start you will need to install python and ffmpeg. You can install python from here and ffmpeg from here.
If you are on Linux or macOS you an install ffmpeg and python using your package manager.
Debian/Ubuntu
Fedora
Arch Linux
macOS
Note: You will need to have Homebrew installed to install ffmpeg.
Windows
You can download the installer for ffmpeg from here and python from here.
Creating the video
First we will need to make a python script that creates the frames for the video. The following script will create a video with random static like frames. Create a file called convert.py
and paste the following code into it:
This script will create a folder called frames
and will create a frame for each bit in the input file. The input file is test.dat
and you can change it to any file you want. The frames will be saved as .ppm
files which are a simple image format that ffmpeg can read.
Now run the script using the following command:
Converting the frames to a video
Now that we have the frames we can convert them to a video using ffmpeg. Run the following command to convert the frames to a video:
This command will create a video called output.mp4
with the frames in the frames
folder. The -r 30
flag sets the frame rate to 30 frames per second. You can change this value to any value you want.
Upscaling the video (optional)
You can upscale the video using ffmpeg to make it look better. Run the following command to upscale the video:
This command will upscale the video to 1000x1000 pixels. You can change the values to any value you want.