MARCELO: an AI bot to automate the editing and thumbnail creation for your Youtube clips channel
This project uses machine learning (AI) to automate the management of your Youtube clips channel by clipping, editing, creating of thumbnails and uploading to your YT channel
Requirements
- Python 3
- Youtube uploader
- OpenCV
- ffmpeg
- Youtube API v3
- ~50GB of free storage (depending of the size of the videos and cuts)
Setup
- Download the latest version of youtubeuploader and extract the executable go file in the project's
./
folder - Configure Youtube API v3 accordingly Youtube Uploader instructions and save
client_secrets.json
in the repo root. - Install python requirements
$ pip install -r requirements.txt
- Populate the folder
./backgrounds
with images.png
to be randomly selected to your thumbnail - Leave a
default_face.png
on./assets
folder just in case the bot is not able to find a smiling face on your video. It will be used as a default face. - Update
description
andmetadata
onmarcelo.py:upload_video
to fit your channel info - [Optional] Leave a
opening.mp4
andending.mp4
videos (MP4 encoded, 1920x1080) onassets/
dir to automatically insert an intro and ending sessions on your edited video
Usage
- Prepare a spreadsheet with the following fields (example ./list-sample.csv):
url | time_from | time_to | podcast | title | description | tags |
---|---|---|---|---|---|---|
https://www.youtube.com/watch?v=[VIDEO_ID] | 00:00:14 | 00:01:46 | 0 | TITLE | DESCRIPTION | tag1 tag2 tag3 tag4 |
https://www.youtube.com/watch?v=[VIDEO_ID2] | 0 | TITLE | DESCRIPTION | tag1 tag2 tag3 tag4 |
- URL: Youtube url
- time_from: Clip start time (leave it blank for the entire video)
- time_to: Clip end time (leave it blank for the entire video)
- podcast: it will extract the edited audio for a podcast (NOT IMPLEMENTED YET - leave it 0)
- title: Video clip title (don't use comma)
- description: Video clip description (don't use comma)
- tags: Video tags splitted by spaces (don't use comma)
-
Save the spreadsheet as a
csv
and place thelists/list.csv
file in the project folder -
Run
marcelo.py
$ python marcelo.py
- [On first run only] it will open a page asking for authorization on Youtube
Docker
It is recommended to run youtubeuploader
mannually and upload at least one video, to generate and store the authorisation file before building the container.
$ docker build -t marcelo .
$ docker run [-it] marcelo
Docker will copy all files to docker root, patch pytube bug and execute from there
- Remember to have your
lists/list.csv
(clips and cuts list) andclient_secrets.json
(Youtube API v3 access) ready in the repo root
You can run Marcelo without building the entire image after updating lists/list.csv
:
$ docker run [-it] -v "$(pwd)/lists:/app/lists" marcelo
PS: running from a container is slower than running on your physical machine. Video editing and machine learning does not perform well inside virtual environments.
How it works
This project execute is executed in 4 phases:
- Download and cut: Download and cut the video if needed
- Editing: A bot will scan the entire video to find audio silences, to cut and edit the video automatically
- Thumbnail: A bot will use machine learning through Computer Vision to find smiling faces in the video, to extract samples and build an unique thumbnail for your channel
- Upload: Prepare the metadata and Upload the video to your Youtube channel
- Marcelo: is a tribute to Marcelo Rezende, a Brazilian journalist and television presenter who used to say 'Corta pra mim'
DEMO
This bot is live, producing the clips channel of the Morning Crypto show.
- Clips: https://www.youtube.com/channel/UCzwLEvNi0__N9BHbgTqJKeQ
- Full videos: https://youtube.com/eddieoz
- Live show on Twitch (every day, 8am BRT): https://twitch.tv/eddieoztv
References
Decentralised repo
This project can be found on Radicle
Known issues
- Issue on
cypher.py
- Youtube changed some internal APIs, not fixed on pytube yet. Solution found on: https://stackoverflow.com/a/71922554
- Line 264:
r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&\s*' r'\([a-z]\s*=\s*([a-zA-Z0-9$]{2,3})(\[\d+\])?\([a-z]\)'
- Line 288:
nfunc=re.escape(function_match.group(1))),
- Youtube changed some internal APIs, not fixed on pytube yet. Solution found on: https://stackoverflow.com/a/71922554
TO-DO
- Automate the podcast creation
- Use ffmpeg GPU
- Select backgrounds based on title and description
- Indexing captions for searching specific spoken phrase on the video
- Automate the creation of the keywords (by using Watson or another NLP)
Buy me a coffee
Did you like it? Buy me a coffee
Or drop me a tip through Lightning Network: âš¡ zbd.gg/eddieoz