YouTube Video Shortifier is a Python-based tool designed to automate the process of downloading, trimming, resizing, and editing YouTube videos into short-form content best for TikTok or YouTube shorts
. It includes features for adding text overlays, watermarks, and outros, making it ideal for content creators looking to repurpose long-form videos into engaging shorts.
- Download Videos: Fetch and download videos from YouTube using the YouTube Data API.
- Trim and Resize: Automatically trim videos to a specified duration and resize them to fit a vertical format.
- Blurry Background: Add a blurred background to fit the video within the target dimensions.
- Text Overlays: Add customizable text overlays with options for padding and rounded corners.
- Watermarks: Include a logo or watermark in the final video.
- Outro Clips: Concatenate an outro clip to the processed video.
- Python 3.x: The script is compatible with Python 3.
- FFmpeg: Required for video processing. Ensure FFmpeg is installed and available in your system's PATH.
- Google API Key: Needed to access the YouTube Data API.
- Dependencies: Install the required Python libraries using
pip
.
-
Clone the Repository
git clone https://github.com/KhamisiKibet/YouTube-Video-Shortifier.git cd YouTube-Video-Shortifier
-
Install Dependencies
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the required libraries:
pip install -r requirements.txt
-
Set Up Environment Variables
Create a
.env
file in the root directory of the project with the following content:YOUTUBE_API_KEY=your_youtube_api_key CHANNEL_ID_YOUTUBE=your_channel_id
Replace
your_youtube_api_key
andyour_channel_id
with your actual API key and YouTube channel ID. -
Install FFmpeg
Ensure FFmpeg is installed on your system. You can download it from FFmpeg's official website and follow the installation instructions.
-
Run the Script
Execute the main script to start processing videos:
python ShortifyYtVideo_Moviepy.py
-
Using the Pure FFmpeg Script:
Moviepy
might be too slow, if you prefer usingFFmpeg
directly without MoviePy, use the ShortifyYtVideo_Ffmpeg.py script. It offers similar functionality but relies solely on FFmpeg for video processing.To run the FFmpeg script:
python ShortifyYtVideo_Ffmpeg.py
The script will:
- Fetch a random video from the specified YouTube channel.
- Download the video and its audio.
- Trim and resize the video.
- Add a blurry background, text overlays, and an optional watermark.
- Concatenate an outro clip.
- Save the final video in the
ShortifiedYtVideos
directory.
-
-
Customize the Script
- Text Overlay: Modify the
break_text
function to adjust text wrapping settings. - Background Blur: Change the
blur
function parameters to adjust the blur effect. - Watermark: Update the
logo_path
variable inmain_flow()
to point to your logo file.
- Text Overlay: Modify the
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, you can reach out to me or open an issue in the GitHub repository.
If you enjoy my projects and find them helpful, consider buying me a coffee. Your support helps me keep going and create more awesome content! 😊