Automating YouTube Shorts with Python
45sShows a step-by-step automation process that saves time and effort, appealing to creators.
▶ Play ClipThe video demonstrates how to automate the creation of YouTube Shorts using Python, leveraging libraries like MoviePy, APIs for stock footage and text-to-speech, and AI for script generation. The creator builds a simple frontend that generates a complete video from a user-provided idea, then tests it on a channel with modest success.
The creator saw random fact YouTube Shorts and decided to automate their creation with Python using minimal effort.
Uses Python with MoviePy for video editing, Bing version of ChatGPT for script generation, Pexels API for stock videos, TikTok TTS unofficial API for text-to-speech, and AssemblyAI for generating subtitles.
A simple frontend allows entering a video idea, which triggers ChatGPT to generate a script and search terms for stock footage.
Pexels API provides free stock videos, but resolution issues required cropping instead of resizing to avoid glitches.
Used TikTok TTS unofficial API for speech, then AssemblyAI to generate a transcript with timestamps in SRT format for subtitles.
The backend generates a video; the creator shows a sample output about the Amazon rainforest. Testing on a channel yielded a few 1K-view shorts.
The project successfully automates YouTube Shorts creation, achieving modest viewership. The creator plans to release the code on GitHub for subscribers.
"Title accurately describes the content: automating YouTube Shorts with Python."
What Python library is used for video editing in this project?
MoviePy
0:19
Which API is used to generate the video script?
Bing version of ChatGPT
0:33
How did the creator fix resolution issues with stock videos?
By cropping instead of resizing
1:05
Which unofficial API was used for text-to-speech?
TikTok TTS unofficial API from GitHub
1:15
What platform was used to generate subtitles with timestamps?
AssemblyAI
1:21
What format did AssemblyAI save the subtitles in?
SRT format
1:29
Automation Motivation
Shows the creator's insight that these videos are easy to automate with little effort.
0:12Cropping Fix
Demonstrates a practical technique to avoid glitches when resizing videos.
0:57Testing Results
Confirms the automation works and can achieve thousands of views.
1:45[00:00] when I was scrolling through YouTube
[00:01] shorts yesterday I came across these
[00:03] videos seeing random facts about the
[00:05] world here's an example meet the
[00:06] immortal jellyfish a mesmerizing
[00:08] creature that defies the boundaries of
[00:10] life and death and I just thought how
[00:12] easy these would be to automate with
[00:13] literally little to no effort here's how
[00:16] that went I wanted to use Python to do
[00:18] this project since you can easily edit
[00:19] videos with it using a library called
[00:22] movie pie and because this is
[00:23] essentially free money method I named it
[00:25] money printer first of all I created a
[00:27] very simple front end where you can
[00:29] enter your video idea and it will
[00:30] automatically generate the video for you
[00:33] since I already know how to use the Bing
[00:35] version of cgt with python from previous
[00:37] projects I let it create a video script
[00:39] based on the provided user idea now that
[00:42] I have the script next up is to find
[00:43] good stock videos based on Search terms
[00:46] that jpt also generated for me for this
[00:48] I used the pixels API which is very easy
[00:50] to use and also free there is one
[00:52] problem however I don't know the
[00:54] resolution of the videos that the pixels
[00:56] API provides me with so I need to
[00:57] manually resize them using movie pie
[00:59] which is a pain since most of the time
[01:01] it simply renders this weird TV glitch
[01:03] screen but somehow I managed to fix it
[01:05] by cropping the video clips instead of
[01:07] resizing them now I had to find a form
[01:09] of Texas speech which didn't sound too
[01:11] robotic but I obviously don't have
[01:13] enough money for the 11 Labs API so we
[01:15] went with a Tik Tok TTS unofficial API
[01:18] from GitHub and it was converting the
[01:19] sentences in my script just fine there's
[01:21] a platform called assembly Ai and this
[01:23] is what I used to get a transcript of my
[01:25] just generated Texas speech as it would
[01:27] include timestamps and it can save the
[01:29] sub it in the SRT format movie piie
[01:32] comes in clutch Again by letting me burn
[01:34] subtitles into the video easily by
[01:36] concatenating the original video file
[01:38] with a subti clip class instance which
[01:40] just needs the path to my just exported
[01:43] SRT file with that the application is
[01:45] basically finished Let's test it out
[01:47] okay let's run our back end all right
[01:49] should be running now let's click on
[01:52] generate and now wait right now it's
[01:55] generating or generating our
[01:58] script it's generated it now these are
[02:01] the Search terms which we are going to
[02:03] use with the pixels API here are the
[02:05] videos it shows now it's downloading
[02:08] those okay it prints the script again
[02:12] now it's completing the text of speech
[02:14] using the Tik Tok API or unofficial API
[02:18] all right now it's generated the
[02:19] subtitles with the assembly Ai and last
[02:23] but not least it's combining everything
[02:24] together and once this is done we should
[02:27] have our output. MP4 I'm going to speed
[02:30] up this process a little bit cuz it's
[02:31] boring all right it seems like we still
[02:34] have to do something so I'm going to
[02:36] take that sacrifice because I'd rather
[02:38] wait a little while than edit all these
[02:40] videos myself so I'm fine with that
[02:43] great now it's done with that said let's
[02:45] have a look at our video the Amazon
[02:48] rainforest is the largest tropical
[02:50] rainforest in the world covering an area
[02:52] of approximately 5.5 million square km
[02:56] it is home to a diverse range of plant
[02:58] and animal species many of which are
[03:01] found nowhere else on Earth this looks
[03:03] good enough just so you don't think this
[03:05] was just some useless project I actually
[03:07] tested these clips on a channel and here
[03:09] are the
[03:11] results as you can see I did get a
[03:14] couple 1K views shorts which is pretty
[03:16] impressive for an automation bot in my
[03:18] opinion if you guys want the code like
[03:20] And subscribe as I'll be posting it on
[03:22] GitHub in the upcoming days till next
[03:28] time oh
⚡ Saved you time reading this? Transcribe any YouTube video for free — no signup needed.