Skip to content

This script reads a CSV file which contains links to images, and metadata for Youtube. The script takes the images and with FMPEG converts it to a video, then this video is uploaded to Youtube using the Metadata in the CSV file.

License

Notifications You must be signed in to change notification settings

sinnet3000/csv2image2video2youtube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV2Img2Video2Youtube (Legacy - Python 2)

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.

Features

  • 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.

How to Use

1. Install Software Dependencies

Ensure you have the following system-level dependencies:

sudo apt-get install ffmpeg

This 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.)

2. Configure YouTube API Credentials (OAuth 2.0)

To allow the script to upload videos to your YouTube channel, you need to create OAuth 2.0 credentials:

  1. Go to the Google Cloud Console.
  2. Create a new project.
  3. Navigate to "APIs & Services" > "Enabled APIs & services" and ensure all YouTube Data API services are enabled.
  4. Go to "APIs & Services" > "Credentials".
  5. Click "CREATE CREDENTIALS" > "OAuth client ID".
  6. Select "Application type" as "Other" and provide a name (e.g., youtube-upload).
  7. Click "Create" and then "OK".
  8. Download the client_secret.json file from the "OAuth 2.0 Client IDs" section.
  9. Place this client_secret.json file in the same directory as the video_creator.py script. (If necessary, you might need to rename it to client_secret_json).

3. Running the Script

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., 5 for 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.

First-time Authentication

The first time you run the script, it will provide a URL in the console. You will need to:

  1. Open this URL in a web browser (this can be done from any computer, not necessarily the server).
  2. Grant the application permission to access your YouTube account.
  3. 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.

Important Notes:

  • 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.

License

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.

About

This script reads a CSV file which contains links to images, and metadata for Youtube. The script takes the images and with FMPEG converts it to a video, then this video is uploaded to Youtube using the Metadata in the CSV file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages