Note: This project contains legacy code, primarily written in Python 2. While it demonstrates a functional approach to generating videos from CSV data and uploading them to YouTube, it is no longer actively maintained and may require significant updates for compatibility with modern systems and best practices. Proceed with caution, especially regarding security and dependencies.
This script automates the process of creating videos from image links specified in a CSV file and uploading them to YouTube with associated metadata. It uses FFmpeg for video creation and the YouTube Data API for uploads. A basic throttling mechanism is included.
- Image to Video Conversion: Uses FFmpeg to convert a series of images into a video.
- YouTube Upload: Integrates with the YouTube Data API to upload the generated video along with metadata (title, description, tags, category, privacy status) from the CSV.
- Configurable Throttle: Includes a rudimentary throttling feature to control the video upload rate.
- OAuth2 Authentication: Handles YouTube API authentication using OAuth2.
Ensure you have the following system-level dependencies:
sudo apt-get install ffmpegThis script was originally developed for Python 2.7. If you intend to run this legacy code, ensure you have a compatible Python 2.7 environment.
Install Python package dependencies:
pip install -r requirements.txt(Note: This requirements.txt file is designed for Python 2.7. Compatibility with Python 3 is not guaranteed without modification.)
To allow the script to upload videos to your YouTube channel, you need to create OAuth 2.0 credentials:
- Go to the Google Cloud Console.
- Create a new project.
- Navigate to "APIs & Services" > "Enabled APIs & services" and ensure all YouTube Data API services are enabled.
- Go to "APIs & Services" > "Credentials".
- Click "CREATE CREDENTIALS" > "OAuth client ID".
- Select "Application type" as "Other" and provide a name (e.g.,
youtube-upload). - Click "Create" and then "OK".
- Download the
client_secret.jsonfile from the "OAuth 2.0 Client IDs" section. - Place this
client_secret.jsonfile in the same directory as thevideo_creator.pyscript. (If necessary, you might need to rename it toclient_secret_json).
Execute the script from your terminal:
python video_creator.py -f [name of csv file] -t [throttle in videos per hour (optional)] &-f [name of csv file]: Specifies the path to your CSV file containing video data.-t [throttle in videos per hour]: Optional. Sets a throttle value (e.g.,5for 5 videos per hour). Default is 30 videos per hour. The throttle range is between 1 and 30 videos per hour.&: Important! The ampersand sends the script to run in the background. This prevents the process from terminating if your SSH connection drops or closes.
The first time you run the script, it will provide a URL in the console. You will need to:
- Open this URL in a web browser (this can be done from any computer, not necessarily the server).
- Grant the application permission to access your YouTube account.
- You will receive an authentication token. Paste this token back into the command line when prompted.
After successful authentication, the script will begin its work. Subsequent runs generally won't require re-authentication unless the YouTube token expires.
- HTML in Description: YouTube will reject video descriptions containing HTML code. Ensure your CSV data for descriptions is plain text to prevent upload failures.
- Image Requirements: The script expects image URLs in the CSV. It handles downloading, resizing (to 1280x720), and converting images for video creation. The first image in the sequence is used as the video thumbnail.
- FFmpeg Bug Workaround: The script includes a workaround for a known FFmpeg bug by copying the last image twice.
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Copyright (C) 2018 Luis Colunga (@sinnet3000). All rights reserved.
See the LICENSE file for full details.