Coder Social home page Coder Social logo

binary-bytes / auto-youtube-shorts-maker Goto Github PK

View Code? Open in Web Editor NEW
259.0 2.0 45.0 7.9 MB

Automatically generate youtube shorts easily with this simple script!

Python 100.00%
automate binary-bytes python script openai openai-api video-maker youtube-shorts youtube-shorts-bot video-generator artificial-intelligence

auto-youtube-shorts-maker's Introduction

Auto Youtube Shorts Maker

๐Ÿค– Automatically generate YouTube shorts simply by running the script!

Description

From creation to editing and voiceover too, this script automates it all for a YouTube short. No more tedious tasks or endless hours, this script has you covered! And the best part? It's absolutely free!

Table of Contents

Installation

Prerequisites

  1. OpenAI API Key - Get it from the Open AI Website. It provides $18 of free credits by default and they are more than enough. [OPTIONAL]
  2. OpenAI - pip install openai
  3. gTTS - pip install gtts
  4. MoviePY - pip install moviepy
  5. Dotenv - pip install python-dotenv

Installing

  1. Download this repository as a zip file or clone it using git.
  2. Open the folder.
  3. Make sure the above-mentioned modules are installed: pip install -r requirements.txt
  4. Add your OpenAI API key to the .env.example file (OPENAI_API=<key>) and rename it to .env [OPTIONAL]
  5. Download both gameplay videos from Google Drive (as they were too large to upload to GitHub)
  6. Put both videos in a folder named "gameplay" in the directory with the shorts.py file.
  7. Run the shorts.py Python file.

Usage

To use this script:

  1. Run the shorts.py Python file.
  2. Enter the name of the video.
  3. Let AI generate video content for you or enter it yourself.
    • NOTE : (Make sure you have added your OpenAI API key in the .env file if using AI to generate content)
  4. And that's it! Everything else will be handled automatically!
  5. You can find your video in the generated/ directory.

Demo

Click Here To See The Demo Video

  • NOTE : This video is trimmed but it shouldn't take more than 1 minute to generate your video.

How it Works

1. Content

The script starts by taking the video name and asking if the user wants to generate content using AI (which can be edited later).

2. Text-to-Speech

After the content is generated/entered by the user, it generates Text-to-Speech and saves the file as speech.mp3.

3. Editing

The editing starts by selecting a gameplay, trimming a random part of it, and adding speech on top of it. Next, it resizes the video to a 9:16 aspect ratio and saves the final video.

Contributing

Note that this script is very basic as of now and does not generate any graphics like images or even subtitles. These are some things that may be added in the future. If you want to contribute, you are free to do so. Feel free to fork and improve this repository.

Due to school, exams, and other real-life commitments, I don't get much time to work on this project. When I do, I would like to add the above-mentioned features. Maybe even a Reddit video maker, but I'm not sure yet.

License

Beep boop, boop beep. I am a script. If there are any issues, contact my [Creator](https://github.com/Binary-Bytes) - BedrockGranny#8331 or bedrockgranny on Discord.

Built Using

  1. OpenAI API - For generating video content.
  2. gTTS - For Text-to-Speech.
  3. MoviePY - For video editing.

auto-youtube-shorts-maker's People

Contributors

akhil3417 avatar binary-bytes avatar oceanofanythingofficial 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

auto-youtube-shorts-maker's Issues

openai chatcompletions not supported

Hi, I believe the code is outdated by now because OpenAI decided to stop supporting openai.completion this is the result I get:
`Enter the name of the video > 5 fun facts
Do you want AI to generate content? (yes/no) > yes

Enter the theme of the video > 5 fun facts
Traceback (most recent call last):
File "c:\Users\Jesper\OneDrive\Documenten\GitHub\Auto-YouTube-Shorts-Maker\shorts.py", line 21, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Jesper\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\lib_old_api.py", line 39, in call
raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1:

You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742`

Dose not provide the expected output

Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 285, in ffmpeg_parse_infos
line = [l for l in lines if keyword in l][index]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\User\Desktop\yt shorts\Auto-YouTube-Shorts-Maker-master\shorts.py", line 61, in
video_clip = VideoFileClip("gameplay/gameplay_" + gp + ".mp4").subclip(start_point, start_point + audio_clip.duration + 1.3)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 88, in init
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 35, in init
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 289, in ffmpeg_parse_infos
raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file gameplay/gameplay_2.mp4.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000025775ed8740] Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000025775ed8740] moov atom not found
gameplay/gameplay_2.mp4: Invalid data found when processing input

openai chatcompletions not supported

Hi, I believe the code is outdated by now because OpenAI decided to stop supporting openai.completion this is the result I get:
`Enter the name of the video > 5 fun facts
Do you want AI to generate content? (yes/no) > yes

Enter the theme of the video > 5 fun facts
Traceback (most recent call last):
File "c:\Users\Jesper\OneDrive\Documenten\GitHub\Auto-YouTube-Shorts-Maker\shorts.py", line 21, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Jesper\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\lib_old_api.py", line 39, in call
raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1:

You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: openai/openai-python#742

image

openai saying rate limit exceeded i am using the free account

the error showing is
Traceback (most recent call last):
File "d:\college\Auto-YouTube-Shorts-Maker\shorts.py", line 21, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\college\Auto-YouTube-Shorts-Maker.venv\Lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\college\Auto-YouTube-Shorts-Maker.venv\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "D:\college\Auto-YouTube-Shorts-Maker.venv\Lib\site-packages\openai\api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\college\Auto-YouTube-Shorts-Maker.venv\Lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response
self._interpret_response_line(
File "D:\college\Auto-YouTube-Shorts-Maker.venv\Lib\site-packages\openai\api_requestor.py", line 763, in _interpret_response_line
raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

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.