Skip to content

ArjunSarkar1/ClipsMaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

YouTube to Shorts Pipeline ๐ŸŽฌ

Automatically convert long-form podcast videos into engaging short-form content by combining them with gameplay footage and adding intelligent subtitles.

๐Ÿš€ Features

  • Automatic Engagement Detection: Uses AI to find the most interesting moments in podcasts
  • Split-Screen Format: Combines podcast (top) and gameplay (bottom) in 9:16 aspect ratio
  • Intelligent Subtitles: Automatically generates and styles subtitles from transcript
  • Audio Analysis: Detects volume spikes, sentiment changes, and speech patterns
  • Text Analysis: Identifies questions, exclamations, and emotional content
  • Batch Processing: Generate multiple clips from a single video
  • YouTube Integration: Download videos directly from YouTube URLs
  • Interactive Mode: User-friendly prompts for video URLs

๐Ÿ“‹ Requirements

For Shorts:

  • โœ… Background music (.mp3) - Coming soon
  • โœ… Captions (.srt) - Automatic generation
  • โœ… Podcast recording video (.mp4) - From YouTube or local file
  • โœ… Gameplay video (.mp4) - From YouTube or local file
  • โœ… Length (15-60 seconds) - Automatic optimization

Optional (Publishing):

  • Title suggestions
  • Description templates
  • Thumbnail generation

๐Ÿ› ๏ธ Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd YoutubeToShorts
  2. Create virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Install FFmpeg (required for video processing):

    • macOS: brew install ffmpeg
    • Ubuntu: sudo apt install ffmpeg
    • Windows: Download from FFmpeg website

๐ŸŽฏ Usage

Interactive Mode (Recommended for beginners)

Simply run the pipeline and enter YouTube URLs when prompted:

python3 clips.py

Or use the CLI with interactive mode:

python3 run_pipeline.py --interactive

The program will:

  1. Ask for podcast YouTube URL
  2. Ask for gameplay YouTube URL
  3. Ask how many clips to generate
  4. Download videos automatically
  5. Process and generate shorts

Command Line Interface

Using YouTube URLs:

# Download from YouTube URLs
python3 run_pipeline.py --podcast-url "https://youtube.com/watch?v=..." --gameplay-url "https://youtube.com/watch?v=..." --clips 5

# Alternative syntax
python3 run_pipeline.py --podcast-youtube "https://youtube.com/watch?v=..." --gameplay-youtube "https://youtube.com/watch?v=..." --clips 5

Using Local Files:

# Use local video files
python3 run_pipeline.py --podcast savedVideos/main_vid.mp4 --gameplay gamePlayVid/gameplay.mp4 --clips 5

Mixed Mode:

# Download podcast from YouTube, use local gameplay
python3 run_pipeline.py --podcast-url "https://youtube.com/watch?v=..." --gameplay gamePlayVid/gameplay.mp4 --clips 5

CLI Options:

  • --podcast-url, -pu: YouTube URL for podcast video
  • --gameplay-url, -gu: YouTube URL for gameplay video
  • --podcast, -p: Path to local podcast video file
  • --gameplay, -g: Path to local gameplay video file
  • --clips, -n: Number of clips to generate (default: 5)
  • --output-dir, -o: Output directory (default: outputs)
  • --verbose, -v: Enable verbose output
  • --interactive, -i: Run in interactive mode

Programmatic Usage

from clips import YouTubeToShortsPipeline

# Initialize pipeline
pipeline = YouTubeToShortsPipeline()

# Download videos from YouTube
podcast_path = pipeline.download_youtube_video(
    "https://youtube.com/watch?v=...",
    "savedVideos",
    "podcast"
)

gameplay_path = pipeline.download_youtube_video(
    "https://youtube.com/watch?v=...",
    "gamePlayVid", 
    "gameplay"
)

# Run complete pipeline
clips = pipeline.process_pipeline(
    podcast_path=podcast_path,
    gameplay_path=gameplay_path,
    num_clips=3
)

print(f"Generated {len(clips)} clips!")

๐Ÿ”ง Pipeline Steps

Step 1: Input Videos

  • Podcast Video: Long-form content (e.g., interviews, discussions) - from YouTube URL or local file
  • Gameplay Video: Background footage (e.g., Minecraft, Fortnite, Valorant) - from YouTube URL or local file

Step 2: Engagement Detection

The system analyzes both audio and text to find high-engagement segments:

Audio Analysis:

  • Volume spikes and changes
  • Spectral centroid (brightness)
  • Zero crossing rate (speech activity)

Text Analysis:

  • Sentiment analysis (positive/negative emotions)
  • Question detection
  • Exclamation detection
  • Laughter patterns
  • Optimal word count

Step 3: Video Combination

  • Extracts high-engagement segments (15-60 seconds)
  • Creates split-screen format (podcast top, gameplay bottom)
  • Optimizes for 9:16 aspect ratio (Shorts format)

Step 4: Subtitle Generation

  • Uses OpenAI Whisper for accurate transcription
  • Automatically times subtitles to audio
  • Styled with white text and black outline
  • Positioned at bottom of screen

๐Ÿ“ Project Structure

YoutubeToShorts/
โ”œโ”€โ”€ clips.py                 # Main pipeline implementation
โ”œโ”€โ”€ run_pipeline.py          # CLI interface
โ”œโ”€โ”€ config.py               # Configuration settings
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ youtubeDownloader.py   # Video download utilities
โ”œโ”€โ”€ test_pipeline.py       # Test script
โ”œโ”€โ”€ savedVideos/           # Downloaded podcast videos
โ”œโ”€โ”€ gamePlayVid/           # Downloaded gameplay videos
โ”œโ”€โ”€ outputs/               # Generated short clips
โ”œโ”€โ”€ transcripts/           # Generated transcripts
โ”œโ”€โ”€ temp/                  # Temporary files
โ””โ”€โ”€ audio_segments/        # Audio processing files

โš™๏ธ Configuration

Edit config.py to customize:

  • Video settings: Resolution, codec, FPS
  • Engagement analysis: Weights, duration limits
  • Subtitle styling: Font, size, colors
  • Whisper settings: Model size, language

๐ŸŽจ Customization

Adding Custom Engagement Patterns

def _analyze_text_engagement(self, text: str) -> float:
    # Add your custom patterns here
    custom_patterns = ['your_keyword', 'another_pattern']
    # ... existing code ...

Custom Subtitle Styling

def make_subtitle(txt):
    return TextClip(
        txt, 
        font='Your-Font', 
        fontsize=50,
        color='yellow',
        stroke_color='blue',
        stroke_width=3
    ).set_position(('center', 'top'))

๐Ÿšจ Troubleshooting

Common Issues

  1. FFmpeg not found:

    # Install FFmpeg first
    brew install ffmpeg  # macOS
    sudo apt install ffmpeg  # Ubuntu
  2. Whisper model download:

    • First run will download the model (~1GB)
    • Ensure stable internet connection
  3. YouTube download issues:

    • Check internet connection
    • Verify YouTube URL is valid
    • Some videos may be restricted
  4. Memory issues:

    • Use smaller Whisper model: Change "base" to "tiny" in config
    • Process shorter videos first
  5. Video format issues:

    • Ensure videos are in common formats (MP4, MOV, AVI)
    • Check video codec compatibility

Performance Tips

  • Use SSD storage for faster processing
  • Close other applications during processing
  • Use smaller Whisper models for faster transcription
  • Process videos in smaller batches

๐Ÿ“ Example Usage

Quick Start with YouTube URLs:

  1. Run interactive mode:

    python3 clips.py
  2. Enter URLs when prompted:

    ๐Ÿ“ป Enter the YouTube URL for the podcast video: https://youtube.com/watch?v=...
    ๐ŸŽฎ Enter the YouTube URL for the gameplay video: https://youtube.com/watch?v=...
    ๐Ÿ“Š How many clips to generate? (default: 3): 5
    
  3. Wait for processing:

    • Videos will be downloaded automatically
    • Audio will be transcribed
    • Engagement segments will be analyzed
    • Short clips will be generated

Using CLI with URLs:

python3 run_pipeline.py \
  --podcast-url "https://youtube.com/watch?v=podcast_video_id" \
  --gameplay-url "https://youtube.com/watch?v=gameplay_video_id" \
  --clips 3 \
  --verbose

๐Ÿ”ฎ Future Enhancements

  • Background music integration
  • Advanced subtitle animations
  • YouTube upload automation
  • Thumbnail generation
  • Multiple gameplay video support
  • Web interface
  • Real-time processing
  • Custom engagement patterns
  • Batch processing from playlists

๐Ÿ“„ License

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

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section
  2. Search existing issues
  3. Create a new issue with detailed information

About

Clips generation from long form content.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages