-
Notifications
You must be signed in to change notification settings - Fork 3
Bad Apple!!
- How it works
- Common errors
- How to edit the code
- About the creator
framer.py is the easiest to understand.
framer.py uses a tool called yt-dlp which will download bad apple off of youtube.
Next, framer.py uses a tool called ffmpeg which takes the video file and turns it into about ~3000 frames (15 frames per second)
an important thing to note is ffmpeg downloads these frames in the format output000001
for the first file then output000002
for the second and so on...
framer.py has finished it's job at this point and passes it onto convert.py
convert.py is rather simple as well
convert.py has a cool algorithm that turns this output069420
into -> new69420
after doing that, convert.py shrinks the image into a much smaller image that is the size of the terminal.
99% of all weird glitches happen here
main.py is hands-down the most complicated file by a mile Before we can go any further explaining how the code works, we need to understand a crucial concept which doubles load time speed. This picture shows what the old Version 1.1 used to do.
As you can see, the poor worker here cannot process all of these frames! Our poor worker is being bullied by the code! But! There is a way to fix this We can spread the load of the files into smaller bits
The worker went from needing to process 3000 frames to only 750! Not only does this run much faster, The worker also does not need to be sad anymore...
With that out of the way, we can continue looking at the code.
We start off with making a list of all the frames. This is the main folder that the master will be in charge of. Each worker has a folder and a house. (A list and a function). Inside of the worker's function, they process there share of the files. Once all of the workers are done working, the master takes there folders and puts them together into the main folder.
Now is a great time to explain what is meant by "processing files". When the workers process the files, they are actually reading the brightness of each pixel in the frames assigned to the worker. Once they read the brightness of the frame, the worker will make a new empty string. Once the string is made, the worker checks the brightness of each pixel and adds a corresponding character depending on the brightness.
here is the chart (255 is max) 255 = @ 200 = & 150 = # 100 = $ 50 = + 30 = - 20 = . <20 = " "
Once the string is done, worker puts it in the folder. The worker will continue doing this around 750 ish times.
At this point the workers are killed off because we don't need them anymore. Now, the master can take the folders of the workers can put it in his folder to use for playing the video.
the master prints the strings packed in the folders then waits a 15th of a second until printing the next one. This is all happening while the music is playing in the background.
Most people enter the wrong values for the size of the terminal. Always double check how many characters can fit in your terminal.
Other than that, many people forget to install vital dependencies. Make sure to run bash ./install.sh to install the deps.
- Read the "How does it work" section here
- Fork the repo
- Make a Pull request
- Wait for review to merge (DON'T MERGE TO MAIN)
I am just a guy who likes python and linux. If you want to say hi, you can message me in discord at Apolloiscool#7891