/youtube-clips-automator

MARCELO: an AI powered bot to automate the editing and thumbnail creation for your Youtube clips channel

Primary LanguagePythonMIT LicenseMIT

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

  1. Download the latest version of youtubeuploader and extract the executable go file in the project's ./ folder
  2. Configure Youtube API v3 accordingly Youtube Uploader instructions and save client_secrets.json in the repo root.
  3. Install python requirements
$ pip install -r requirements.txt
  1. Populate the folder ./backgrounds with images .png to be randomly selected to your thumbnail
  2. 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.
  3. Update description and metadata on marcelo.py:upload_video to fit your channel info
  4. [Optional] Leave a opening.mp4 and ending.mp4 videos (MP4 encoded, 1920x1080) on assets/ dir to automatically insert an intro and ending sessions on your edited video

Usage

  1. 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)
  1. Save the spreadsheet as a csv and place the lists/list.csv file in the project folder

  2. Run marcelo.py

$ python marcelo.py
  1. [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) and client_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:

  1. Download and cut: Download and cut the video if needed
  2. Editing: A bot will scan the entire video to find audio silences, to cut and edit the video automatically
  3. 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
  4. Upload: Prepare the metadata and Upload the video to your Youtube channel
  5. 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.

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))),

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

Buy me a coffee

Or drop me a tip through Lightning Network: ⚡ zbd.gg/eddieoz