Git Product home page Git Product logo

youtube-clips-automator's Introduction

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

youtube-clips-automator's People

Contributors

eddieoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

youtube-clips-automator's Issues

Problem running youtubeuploader

Related to #2 by @jaonoctus

When running for the first time, youtubeuploader needs to open a browser, get the account authorization and the browser try to access an URL on localhost (youtubeuploader stays listening for the callback).

Issue with list.csv

Related to #2 from @jaonoctus

I think that the format of the list.csv is outdated. Generated a thumbnail and the title there was "0" (from the podcast field).

Cortes automatizados

Já pensou em adicionar uma feature para fazer "cortes" igual o de podcasts ? não só tirar as partes sem som.. mas talvez fazer um algoritmo ou usar uma lib que identifica "risadas" ou "sorrisos" no video e faz os cortes..

Review the possibility of changing mc.png

Related to #2 from jaonoctus

I could not modify the mc.png to other image.

marcelo    | Traceback (most recent call last):
marcelo    |   File "./thumb_generator.py", line 216, in <module>
marcelo    |     main(args.input, args.title, args.no_delete_thumbs)
marcelo    |   File "./thumb_generator.py", line 185, in main
marcelo    |     create_thumbnail(input, title, delete_thumbs)
marcelo    |   File "./thumb_generator.py", line 155, in create_thumbnail
marcelo    |     face = find_smile(frame,text, count)
marcelo    |   File "./thumb_generator.py", line 65, in find_smile
marcelo    |     add_background(resizeimg, text)
marcelo    |   File "./thumb_generator.py", line 96, in add_background
marcelo    |     newimg.paste(mclogo, (W-mclogo_width-5,5), mclogo)
marcelo    |   File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 1557, in paste
marcelo    |     self.im.paste(im, box, mask.im)
marcelo    | ValueError: bad transparency mask

Could not install requirements

Description

First I tried to run pip install -r requirements,

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements'

Then, tried pip install -r requirements.txt

Collecting absl-py==0.13.0
  Using cached absl_py-0.13.0-py3-none-any.whl (132 kB)
Collecting aiohttp==3.8.1
  Using cached aiohttp-3.8.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.3 MB)
Collecting aiosignal==1.2.0
  Using cached aiosignal-1.2.0-py3-none-any.whl (8.2 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3103, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 101, in __init__
    raise InvalidRequirement("Invalid URL given")
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid URL given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 357, in run
    resolver.resolve(requirement_set)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 270, in _get_abstract_dist_for
    skip_reason = self._check_skip_installed(req)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 228, in _check_skip_installed
    req_to_install.check_if_exists(self.use_user_site)
  File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 443, in check_if_exists
    self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 480, in get_distribution
    dist = Requirement.parse(dist)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3150, in parse
    req, = parse_requirements(s)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3096, in parse_requirements
    yield Requirement(line)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3105, in __init__
    raise RequirementParseError(str(e))
pkg_resources.RequirementParseError: Invalid URL given

Environment

  • Python version: 3.8.10
  • ffmpeg version: 4.2.4
  • OS: 5.10.16.3-microsoft-standard-WSL2

Create output/ folder

Related to #2 from jaonoctus

Would be nice to move all files to a specific folder (e.g. /output) instead of /, so we can create a binding/mount to export files to the host machine after running the container.

What python are you using?

I installed python 3.11 from chocolatey.
Then I run requirements.txt and one of the dependencies couldn't be installed.

Poderia me ajudar?

Traceback (most recent call last):
File "C:\Users\Douglas\Desktop\youtube\jumpcutter.py", line 147, in
INPUT_FILE, frameRate, FRAME_SIZE = downloadFile(args.url, args.title)
File "C:\Users\Douglas\Desktop\youtube\jumpcutter.py", line 42, in downloadFile
newname = title.replace(' ','_')+'.mp4'
AttributeError: 'NoneType' object has no attribute 'replace'
'ab_channel' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
A sintaxe do comando está incorreta.

Dockerfile

Description

Even with #1 solved, I still need to install some other dependencies and cannot run the code. Would be nice to have a Dockerfile, so we can ensure that this will work in any environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.