Automating YouTube Fame

In the process of upskilling in python I created a couple of mini projects. However this is the one that seemed to have come to fruition. 
I created a fully automated pipeline that reads a lists of pre compiled jokes, convert it to video format then export it to YouTube. All with the “click of a button” as they say.

I created two main scripts. One to generate the videos based on the input from the text file. The other to upload the video to YouTube once a quick spot check has been done. 

Below is a quick diagram on the inner workings:


The text and fonts:
A text file was created with a list of jokes. The punchline was split by an “#” so that the script knew where to split the joke into it’s parts. Once the joke was processed it was removed from the text file. The split joke was names JokeA and JokeB because reasons. It was then converted to an image after going thought some text wrapping to make sure it would fit in the dimensions of the video. The text was also rendered using a random selection of 10 fonts I downloaded. Lastly the text was rendered using a white color with big black borders so that it would stand out on any background, light or dark. 

The backgrounds:
I downloaded about 50 animated backgrounds from YouTube. As the aspect ratio was mostly 16:9 I found a script to crop and convert them to the “short” video aspect ratio YouTube uses.
From the 50 videos about 35 to 40 was useable and they went into a folder where they could be randomly selected from to form the background of the video. 

Ending drum roll:
I also downloaded 4 versions of the classic drumroll to play at the end of each video. 

Text to speech:
This was the most fun part as I used AWS’s AIP to generate the voices for the video using AWS Polly where the text where converted to audio in .mp3 format and download all via the API.
From the multitude of voices I ended up choosing 5 voices that is chosen randomly to give each video a bit more variety.

Combining it all:
One all the variables and input parameters where set they all could be combined into one video. The length of the video was determined by adding the length of the two .mp3 files containing the two sections of the joke and the length of the drum roll sound at the end. Once this was known a video clip could be rendered starting with the first part of the joke’s text, using the images of the text’s white background as a mask. This was when overlaid on top of the background and the audio clip of the first joke was synced with it. The second part of the joke followed after that and the drum roll sound was added at the end. And there you have it. A video is produced from just a line of text. Everything automatically. 

Uploading the video:
After obtaining an API key to you my youtube channel I used this to upload each video. Using the first part of the joke as the description and the title because as this point I just wanted to end this project and move on to bigger and better things. I also calculated the dates for each Monday for the next couple of years and used this to schedule each video to be released every Monday for the next couple of years.

If you feel like looking at the code or using it some way feel free to view it on Github

Lastly if you feel so inclined to view the some of the videos or want a laughs every Monday feel free to check our of subscribe using using the Channel link

Hope I made your day a little bit better with me learning a new programming language.