https://github.com/flyingfathead/youclipper
A quick `yt-dlp` and `ffmpeg` utilizing Python tool to clip a i.e. a YouTube video
https://github.com/flyingfathead/youclipper
Last synced: 12 months ago
JSON representation
A quick `yt-dlp` and `ffmpeg` utilizing Python tool to clip a i.e. a YouTube video
- Host: GitHub
- URL: https://github.com/flyingfathead/youclipper
- Owner: FlyingFathead
- Created: 2024-03-07T20:42:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-30T15:59:47.000Z (about 2 years ago)
- Last Synced: 2025-07-02T07:39:50.762Z (12 months ago)
- Language: Python
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# youclipper
`youclipper` is a Python-based command-line tool that leverages `yt-dlp` and `ffmpeg` to download and clip sections from online videos, such as those available on YouTube. It allows you to specify the exact start and end times, even down to milliseconds, to get the precise clip you need. You can also use the included `yousubtitler` to automatically create hard subtitles for your created clips.
## Features
- Download videos from YouTube and other platforms supported by `yt-dlp`.
- Clip videos to your specified start and end times with support for millisecond precision.
- Output your clip directly to a specified filename.
- Subtitle your clips with word-level highlighting.
## Installation
Before you use `youclipper`, ensure you have the following dependencies installed (or use the included `requirements.txt` with `pip install -r requirements.txt`):
- Python 3
- `yt-dlp`
- `ffmpeg`
- `openai-whisper` (or `whisperx`)
- `moviepy`
You can install `yt-dlp` and `ffmpeg` using your operating system's package manager or download them directly from their official websites.
Here's how you can install `ffmpeg` on commonly used operating systems:
```bash
# On Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# On Windows using Chocolatey
choco install ffmpeg
# On MacOS using Homebrew
brew install ffmpeg
```
### Optional Dependencies
To install optional dependencies like `whisperx`, run:
```sh
pip install git+https://github.com/m-bain/whisperx.git
```
## Usage
To view all available commands and their descriptions, you can use the `--help` flag:
```bash
python youclipper.py --help
```
### Basic Clipping
To clip a video without specifying milliseconds:
```bash
python youclipper.py --url --start mm:ss --end mm:ss --output
```
### Clipping with Millisecond Precision
To clip a video and specify times down to the millisecond:
```bash
python youclipper.py --url --start mm:ss.xxx --end mm:ss.xxx --output
```
Note: Replace with the actual URL of the video you wish to clip, mm:ss with the start and end times in minutes and seconds, xxx with milliseconds, and with the desired name of your output file (without adding the .mp4 extension, as it is appended automatically).
### Subtitling Your Clips
You can use the included yousubtitler.py to subtitle your videos. This requires `ImageMagick` as well as the `moviepy` and `openai-whisper` (or `whisperx`) pip packages:
```bash
python yousubtitler.py inputfile.mp4
```
This will automatically create a subtitled version of your clip which will be in the format: `_subtitled.mp4`.
### Configuration Flag for Subtitling
To choose between `openai-whisper` and `whisperx` for subtitling, set the `USE_WHISPERX` flag in `yousubtitler.py`:
```python
# yousubtitler.py
USE_WHISPERX = True # Set to False to use OpenAI's Whisper
```
## Changelog
- v0.14 - (yousubtitler) ditched pydub; using ffmpeg for all audio+video from now on
- v0.13 - (yousubtitler) normalize audio to -0.1dBFS by default (can be set via true/false on `NORMALIZE_AUDIO` variable)
- v0.12 - (yousubtitler) text animations (can be configured from `yousubtitler.py`)
- v0.11 - (yousubtitler) added confirmation prompts for all subtitle entries + confirm overwrites
- v0.10 - (yousubtitler) check for CUDA compatible GPU availablility on launch
- v0.09 - (yousubtitler) added support for word-level highlighting subtitles using `whisperx` or `openai-whisper`.
- v0.08 - (yousubtitler) included `yousubtitler.py` for quick, automatic hard subtitling of clips
- v0.07 - (youclipper) recode instead of copying when clipping to avoid video/audio desync issues
- v0.06 - (youclipper) first public release
## Contributing
Contributions to youclipper are welcome! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request.
## About
Developed by FlyingFathead, with ghostcode by ChaosWhisperer.
- [FlyingFathead on GitHub](https://github.com/FlyingFathead/)
- [youclipper on GitHub](https://github.com/FlyingFathead/youclipper)