Skip to main content

Split long livestream recordings into YouTube-friendly segments with CLI and Web UI

Project description

Livestream Splitter

A powerful tool to split long livestream recordings into digestible segments with customizable intro and outro sequences. Perfect for Kick streamers and content creators who want to repurpose their long-form content for different platforms.

โœจ Features

  • Automatic Video Splitting: Split videos into segments with configurable maximum duration (default: 20 minutes)
  • Intro/Outro Integration: Add custom intro and outro videos to each segment
  • Multiple Format Support: Works with MP4, MKV, AVI, MOV, FLV, WEBM, and TS files
  • Smart File Naming: Configurable naming patterns with date and segment numbering
  • Quality Control: Adjustable output quality and codec settings
  • Progress Tracking: Real-time progress bars and detailed logging
  • Configuration Files: Save and reuse processing configurations
  • Cross-Platform: Works on Windows, macOS, and Linux

๐Ÿš€ Quick Start

Installation

Option 1: Install from PyPI (Recommended)

Prerequisites: Make sure FFmpeg is installed on your system:

# Ubuntu/Debian
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Windows: Download from https://ffmpeg.org/download.html

Install the package:

# Install core functionality
pip install livestream-splitter

# Or install with web UI support
pip install livestream-splitter[web]

# Or install with all optional features
pip install livestream-splitter[all]

Option 2: Install from Source

  1. Install system dependencies:

    # Ubuntu/Debian
    sudo apt install ffmpeg python3.12-venv
    
    # macOS
    brew install ffmpeg
    
    # Windows
    # Download FFmpeg from https://ffmpeg.org/download.html
    
  2. Set up the project:

    # Clone the repository
    git clone <repository-url>
    cd livestream-splitter
    
    # Create virtual environment
    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
    # Install dependencies
    pip install -r requirements.txt
    
  3. Verify installation:

    # Check FFmpeg
    ffmpeg -version
    
    # Test CLI (if installed from PyPI)
    stream-splitter --help
    
    # Test CLI (if installed from source)
    python -m src.stream_splitter.cli --help
    

Basic Usage

Split a video into 20-minute segments:

stream-splitter my_livestream.mp4

With custom output directory and segment length:

stream-splitter my_livestream.mp4 -o segments/ -l 15m

Add intro and outro to each segment:

stream-splitter my_livestream.mp4 --intro intro.mp4 --outro outro.mp4

๐Ÿ“– Detailed Usage

Command Line Options

stream-splitter [OPTIONS] INPUT_FILE

Options:
  -o, --output-dir PATH       Output directory for segments [default: ./segments]
  -l, --max-length TEXT       Maximum segment length (e.g., 20m, 1200s, 1h30m) [default: 20m]
  --intro PATH               Path to intro video file
  --outro PATH               Path to outro video file
  -f, --format [mp4|mkv|avi|mov]  Output format for segments [default: mp4]
  --naming-pattern TEXT      Naming pattern for output files [default: {title}_part{index:02d}_{date}]
  --quality [high|medium|low] Output quality preset [default: high]
  --threads INTEGER          Number of threads for processing [default: 4]
  -c, --config PATH          Configuration file (YAML or JSON)
  --save-config PATH         Save current configuration to file
  -v, --verbose              Enable verbose logging
  --help                     Show this message and exit.

Time Format Examples

The --max-length option accepts various time formats:

  • 20m or 20min โ†’ 20 minutes
  • 1200 or 1200s โ†’ 1200 seconds
  • 1h30m โ†’ 1 hour 30 minutes
  • 1:30:00 โ†’ 1 hour 30 minutes (HH:MM:SS)
  • 90:00 โ†’ 90 minutes (MM:SS)

Configuration Files

Create a configuration file to save your settings:

# config.yaml
input_path: "my_livestream.mp4"
output:
  directory: "./segments"
  format: "mp4"
  naming_pattern: "{title}_segment{index:02d}_{date}"
  max_segment_length: 1200  # 20 minutes

intro_outro:
  intro_path: "intro.mp4"
  outro_path: "outro.mp4"

processing:
  quality: "high"
  codec: "h264"
  preset: "medium"
  threads: 4

Use the configuration file:

stream-splitter -c config.yaml my_livestream.mp4

Save current settings to a config file:

stream-splitter my_livestream.mp4 -l 15m --intro intro.mp4 --save-config my_settings.yaml

๐ŸŽฏ Use Cases

Content Creator Workflow

  1. Stream on Kick: Create long-form content (2-4 hours)
  2. Download VOD: Use third-party tools to download the recording
  3. Split Content: Use this tool to create 20-minute segments
  4. Cross-Platform: Upload segments to YouTube, TikTok, or other platforms

Example Commands

Basic splitting for YouTube uploads:

stream-splitter "My Gaming Stream 2024-01-15.mp4" -o youtube_segments/ -l 20m

With branded intro/outro for professional content:

stream-splitter stream.mp4 \
  --intro channel_intro.mp4 \
  --outro subscribe_outro.mp4 \
  --naming-pattern "Stream_{date}_Part{index:02d}" \
  -o branded_content/

High-quality processing for archival:

stream-splitter stream.mp4 \
  --quality high \
  --format mkv \
  --threads 8 \
  -o archive/

๐Ÿ”ง Advanced Features

File Naming Patterns

Customize output filenames using these variables:

  • {title}: Original filename (sanitized)
  • {index}: Segment number (use :02d for zero-padding)
  • {date}: Current date (YYYYMMDD format)

Examples:

  • {title}_part{index:02d}_{date} โ†’ stream_part01_20240115
  • Segment{index:03d}_{title} โ†’ Segment001_my_stream
  • {date}_{title}_{index} โ†’ 20240115_stream_1

Quality Settings

  • High: Best quality, larger file sizes (CRF 18-23)
  • Medium: Balanced quality and size (CRF 23-28)
  • Low: Smaller files, lower quality (CRF 28-35)

Processing Optimization

  • Use more threads (--threads 8) for faster processing on multi-core systems
  • Choose appropriate presets: ultrafast, fast, medium, slow
  • Monitor disk space - output can be 1.5-2x the input size

๐Ÿ› ๏ธ Development

Project Structure

livestream-splitter/
โ”œโ”€โ”€ src/stream_splitter/     # Main package
โ”‚   โ”œโ”€โ”€ cli.py              # Command-line interface
โ”‚   โ”œโ”€โ”€ config.py           # Configuration handling
โ”‚   โ”œโ”€โ”€ splitter.py         # Main splitting logic
โ”‚   โ”œโ”€โ”€ video_processor.py  # FFmpeg operations
โ”‚   โ””โ”€โ”€ utils.py            # Helper functions
โ”œโ”€โ”€ tests/                  # Test suite
โ”œโ”€โ”€ web/                    # Web UI (future)
โ”œโ”€โ”€ config/                 # Default configurations
โ””โ”€โ”€ examples/               # Usage examples

Running Tests

pip install -e ".[dev]"
pytest tests/

Building from Source

git clone <repository-url>
cd livestream-splitter
pip install -e .

๐Ÿ› Troubleshooting

Common Issues

"FFmpeg not found"

  • Ensure FFmpeg is installed and in your PATH
  • Run stream-splitter check-ffmpeg to verify

"Memory error with large files"

  • Reduce thread count (--threads 2)
  • Process smaller segments first
  • Ensure sufficient RAM (8GB+ recommended for 4K videos)

"Incompatible video formats"

  • Convert intro/outro to match main video format
  • Use same resolution and codec for all inputs

"Permission denied errors"

  • Check write permissions to output directory
  • Run with administrator privileges if needed

Getting Help

  • Check the logs in segments/splitter.log
  • Use --verbose flag for detailed output
  • Report issues on GitHub

๐Ÿ“‹ Requirements

  • Python: 3.8 or higher
  • FFmpeg: Latest stable version
  • Disk Space: 2-3x the input file size for processing
  • RAM: 4GB minimum, 8GB+ recommended for large files

๐ŸŒ Web UI

The project includes a modern web interface for easy video processing!

Starting the Web UI

# Quick start
./start_web_ui.sh

# Or manually
source venv/bin/activate
cd web/backend
uvicorn main:app --reload

Then open your browser to: http://localhost:8000

Web UI Features

  • Drag & Drop Upload: Simply drag your video file onto the page
  • Real-time Progress: Watch your video being processed with live updates
  • Download Manager: Easy access to all processed segments
  • Job History: Track all your processing jobs
  • Mobile Friendly: Works on tablets and phones too

See WEB_UI_GUIDE.md for detailed usage instructions.

๐Ÿš€ Future Features

  • Batch Processing: Process multiple files simultaneously
  • Smart Splitting: Scene detection and natural break points
  • Direct Integration: Download directly from Kick when API supports it
  • Cloud Processing: Optional cloud-based processing
  • AI Highlights: Automatic detection of engaging moments
  • Scheduled Processing: Set up automatic processing workflows

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

โญ Support

If this tool helps you create better content, consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs and issues
  • ๐Ÿ’ก Suggesting new features
  • ๐Ÿ“– Improving documentation

Made for Kick streamers, by content creators ๐ŸŽฎโœจ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livestream_splitter-0.1.0.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livestream_splitter-0.1.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file livestream_splitter-0.1.0.tar.gz.

File metadata

  • Download URL: livestream_splitter-0.1.0.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for livestream_splitter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18e3b8a7c61ac01f4c9ab6a78e5783f1c4e6cc81fc734f29dba156aadd68a535
MD5 659a41acf4704e1af225db1b638797f1
BLAKE2b-256 fadb8a1f2ba98a0fd1d432dccee1016806287acd9ba76bba962ad8f70229f64f

See more details on using hashes here.

File details

Details for the file livestream_splitter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for livestream_splitter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd48046c1f0a41d99c6b8856e982df2c54c3c871fc5db69154304e22963a1ad
MD5 b280105ccdb65c73efee570e8826e278
BLAKE2b-256 fcfdfa663369744a37446f55f34bad8529634685e547f3b1afe13009dfbd4c39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page