quine_video.avi

quine_video.avi

Channel:
Subscribers:
9,600
Published on ● Video Link: https://www.youtube.com/watch?v=RSzNEo8cf6g



Duration: 0:13
5,895 views
222


https://pastebin.com/DC8QvA7K

The Python code has 3 major parts:

1. Converting a code string into video frames, showing the string being written with scrolling support.
This of course requires a font. The font is included in the code with the 10 lines of compressed bytes, giving a simple pixel list with the font data when uncompressed. Python list slicing was very useful for overwriting the video frame list, though not being able to use numpy made it more difficult.

2. Writing video frames into a video file.
This step was time consuming, because I didn't want to rely on external libraries. After several hours searching I found the LCL codec that uses zlib to compress video frames, and zlib is included with Python. The rest was following AVI specifications and creating code shortcuts for writing a proper file.

3. Passing its own source code to the video creation.
This is the Quine part of the video. The code reading its own file is not allowed, so it has to manually construct the source code string. This requires every part of the code to appear at least twice. With some tricks it's possible to put the string construction code into the constructed string itself, avoiding an infinite loop of converting the code into a string, then converting the code that converted the code into a string into a string, etc.

Executing the code takes roughly 40 seconds and it generates this 12.4 MB quine_video.avi file with a SHA-1 of DD9F3B3DEC4AC5D8121640454F21839DAA250F1F.