short-video-maker

repository·main·Indexed 22 days ago

https://github.com/gyoridavid/short-video-maker

An automated tool for generating short-form video content for TikTok, Instagram Reels, and YouTube Shorts from text prompts. It orchestrates Kokoro TTS for speech, Whisper for captioning, Pexels for stock footage, and Remotion for composition. The tool is available as a REST API and a Model Context Protocol (MCP) server, allowing integration with AI agents like n8n. Version 1.3.4.

Tokens
7.8K
Snippets
12
Records
54
Agent score
79%

What's inside short-video-maker

  1. Overview of Short Video Maker

    main
    Short Video Maker is an open-source automated tool for generating short-form video content from text inputs. It automates the process of text-to-speech (using Kokoro TTS), caption generation (using Whisper), background video selection (via Pexels), and video composition (using Remotion). The tool serves both as a REST API and a Model Context Protocol (MCP) server, making it suitable for integration with AI agents like n8n.
  2. Understand the 'Scene' concept

    main

    Videos are assembled from multiple Scenes. Each scene consists of two primary components:

    1. Text: The narration that the Text-to-Speech (TTS) engine reads and from which captions are generated.
    2. Search terms: Keywords used to find relevant background videos via the Pexels API. If no specific terms are provided or found, the system uses 'joker terms': nature, globe, space, or ocean.
  3. Run Short Video Maker via NPM

    main

    While Docker is recommended, you can run the server via npm or npx.

    Supported Platforms:

    • Ubuntu (≥ 22.04): Requires git, wget, cmake, ffmpeg, curl, make, and several system libraries (libsdl2-dev, libnss3, libgbm-dev, etc.).
    • macOS: Requires ffmpeg (install via brew install ffmpeg) and Node.js (tested on 22+).
    • Windows: NOT supported due to whisper.cpp installation issues.
  4. Run Short Video Maker with Docker Compose

    main

    Use Docker Compose to integrate Short Video Maker with other services like n8n. If using the Self-hosted AI starter kit, ensure you add networks: ['demo'] to the service configuration so n8n can reach it at http://short-video-maker:3123.

    version: "3"
    
    services:
      short-video-maker:
        image: gyoridavid/short-video-maker:latest-tiny
        environment:
          - LOG_LEVEL=debug
          - PEXELS_API_KEY=
        ports:
          - "3123:3123"
        volumes:
    	    - ./videos:/app/data/videos # expose the generated videos
  5. How to add new music to the project

    main

    To expand the music library, follow these two steps:

    1. Place your MP3 file into the static/music/ directory.
    2. Register the file in src/short-creator/music.ts by adding a new object to the musicList array. The object must specify the filename, the start and end timestamps (in seconds), and the corresponding MusicMoodEnum value.
    {
      file: "your-new-music-file.mp3",  // Filename of your MP3
      start: 5,                        // Start time in seconds (when to begin playing)
      end: 30,                          // End time in seconds (when to stop playing)
      mood: MusicMoodEnum.happy,        // Mood tag for the music
    }
  6. Run Short Video Maker using Docker

    main

    Docker is the recommended method for deployment. There are three specialized images based on your hardware and resource availability:

    Uses tiny.en Whisper model and q4 quantized Kokoro model. Optimized for low RAM/CPU with CONCURRENCY=1 and a 2GB video cache.

    docker run -it --rm --name short-video-maker -p 3123:3123 -e LOG_LEVEL=debug -e PEXELS_API_KEY= <YOUR_KEY> gyoridavid/short-video-maker:latest-tiny

    Normal

    Uses base.en Whisper model and fp32 Kokoro model. Optimized for standard resources.

    docker run -it --rm --name short-video-maker -p 3123:3123 -e LOG_LEVEL=debug -e PEXELS_API_KEY= <YOUR_KEY> gyoridavid/short-video-maker:latest

    Cuda (For Nvidia GPU users)

    Uses medium.en Whisper model with GPU acceleration and fp32 Kokoro model.

    docker run -it --rm --name short-video-maker -p 3123:3123 -e LOG_LEVEL=debug -e PEXELS_API_KEY= <YOUR_KEY> --gpus=all gyoridavid/short-video-maker:latest-cuda
    docker run -it --rm --name short-video-maker -p 3123:3123 -e LOG_LEVEL=debug -e PEXELS_API_KEY= gyoridavid/short-video-maker:latest-tiny
  7. Deploy short-video-maker to a VPS

    main

    When deploying to a cloud VPS, follow these recommendations:

    • OS: Ubuntu ≥ 22.04
    • Hardware: ≥ 4GB RAM, ≥ 2 vCPUs, and ≥ 5GB storage
    • Process Management: Use pm2 to run and manage the server process.
    • Environment Variables: Store your configuration in the .bashrc file or a similar environment management tool.
  8. General Requirements for Short Video Maker

    main

    To run Short Video Maker, ensure your environment meets the following requirements:

    • Internet access: Required for Pexels API and potentially other services.
    • Pexels API Key: A free key is required for background video sourcing.
    • RAM: Minimum 3 GB (4 GB recommended).
    • CPU: Minimum 2 vCPUs.
    • Disk Space: Minimum 5 GB.
  9. Connect n8n to short-video-maker

    main

    The connection URL between n8n and the short-video-maker server depends on your deployment architecture:

    short-video-maker Locationn8n Local (n8n start)n8n Dockern8n Cloud
    Dockerhttp://localhost:3123http://short-video-maker:3123 (if on same network) or http://host.docker.internal:3123Requires cloud deployment of maker
    NPM/NPXhttp://localhost:3123http://host.docker.internal:3123Requires cloud deployment of maker
    Cloudhttp://{YOUR_IP}:3123http://{YOUR_IP}:3123http://{YOUR_IP}:3123
  10. Core components of the ShortCreator

    main

    The ShortCreator class is the central orchestrator of the video generation process. It requires the following initialized components to function:

    • Config: Application configuration.
    • Remotion: Video rendering engine.
    • Kokoro: Text-to-speech (TTS) engine.
    • Whisper: Speech-to-text (STT) engine.
    • FFMpeg: Media processing utility.
    • PexelsAPI: Stock video footage provider.
    • MusicManager: Handles music file management and availability.
  11. Configure Short Video Maker environment variables

    main

    🟢 Application Configuration

    keydescriptiondefault
    PEXELS_API_KEYYour free Pexels API key
    LOG_LEVELPino log levelinfo
    WHISPER_VERBOSEWhether to forward whisper.cpp output to stdoutfalse
    PORTThe port the server will listen on3123

    ⚙️ System Configuration

    keydescriptiondefault
    KOKORO_MODEL_PRECISIONThe size of the Kokoro model to use. Valid options: fp32, fp16, q8, q4, q4f16depends on Docker image
    CONCURRENCYNumber of parallel browser tabs for Remotion rendering. Lowering this helps on limited hardware.depends on Docker image
    VIDEO_CACHE_SIZE_IN_BYTESCache size for Remotion OffthreadVideo frames.depends on Docker image
  12. Configure Video Generation Options

    main

    When making requests to the API, you can specify the following configuration options to customize the output video:

    keydescriptiondefault
    paddingBackEnd screen duration (in milliseconds) after narration finishes.0
    musicMood of background music. Use values from the GET /api/music-tags endpoint.random
    captionPositionPosition of captions: top, center, or bottom.bottom
    captionBackgroundColorBackground color of the active caption item.blue
    voiceThe Kokoro voice identifier (e.g., af_heart).af_heart
    orientationVideo orientation: portrait or landscape.portrait
    musicVolumeBackground music volume: low, medium, high, or muted.high