ShortGPT Documentation

repository·stable·Indexed 27 days ago

https://github.com/rayventura/shortgpt

An AI-powered video automation framework for creating short-form and long-form content. ShortGPT automates scriptwriting, voiceover synthesis, asset sourcing, and editing using LLMs. It features specialized engines like ContentShortEngine, ContentVideoEngine, ContentTranslationEngine, and EditingEngine, integrating technologies such as Moviepy, OpenAI, ElevenLabs, EdgeTTS, Pexels, and Bing Images.

Tokens
13.9K
Snippets
40
Records
92
Agent score
93%

What's inside ShortGPT

  1. Overview of ShortGPT Engines

    stable

    ShortGPT provides specialized engines for different content creation tasks:

    • ContentShortEngine: Designed for creating short-form content (Shorts). It handles the full pipeline from script generation to final rendering, including YouTube metadata.
    • ContentVideoEngine: Optimized for longer videos. It manages audio generation, automatic background footage sourcing, caption timing, and background asset preparation.
    • ContentTranslationEngine: Used for dubbing and translating videos. It takes a video file or YouTube link, transcribes the audio, translates the content, voices it in a target language, and adds captions.
    • EditingEngine: An automated engine that uses an Editing Markup Language and JSON to break down editing into manageable blocks suitable for Large Language Models (LLMs).
  2. Use FactsShortEngine to generate fact-based short videos

    stable

    The FactsShortEngine is a specialized content engine in ShortGPT designed to automate the creation of short videos centered around interesting facts. It handles script generation, voice synthesis, image searching, and video rendering.

    To use it, you must initialize it with a VoiceModule, a facts_type (the topic), background assets, and language settings. You then call makeContent() to execute the generation pipeline and get_video_output_path() to retrieve the final file location.

  3. Install Python 3.10.3

    stable

    Download, configure, and install Python 3.10.3 from source. Use python3.10 to check the version and pip3.10 to install packages.

    wget https://www.python.org/ftp/python/3.10.3/Python-3.10.3.tgz 
    tar xzf Python-3.10.3.tgz 
    cd Python-3.10.3 
    ./configure --enable-optimizations
    make install
    
    # Verification
    python3.10 -V
    # Usage
    pip3.10 install <package-name>
  4. Configure environment variables for ShortGPT Docker

    stable

    Before running the ShortGPT Docker container, create a .env file in your project root containing the required API keys for the various services used by the framework. Ensure you replace the placeholder text with your actual credentials.

    GEMINI_API_KEY=put_your_gemini_api_key_here
    OPENAI_API_KEY=sk-_put_your_openai_api_key_here
    ELEVENLABS_API_KEY=put_your_eleven_labs_api_key_here
    PEXELS_API_KEY=put_your_pexels_api_key_here
  5. Install system dependencies for Debian 11

    stable

    Update your package list and install the necessary build and development libraries required for ShortGPT and FFmpeg.

    sudo apt update && sudo apt upgrade 
    sudo apt install wget git libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype6-dev liblcms2-dev libxml2-dev wget build-essential libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
  6. Install FFmpeg for ShortGPT

    stable

    ShortGPT requires FFmpeg to function. Installation steps depend on your operating system:

    • Windows: Download the FFmpeg binaries (specifically FFmpeg_Full.msi) from the icedterminal/ffmpeg-installer releases. The installer includes ffmpeg and ffprobe and should add them to your system PATH.
    • macOS: Use Homebrew to install FFmpeg.
    • Ubuntu/Debian: Use apt-get to install FFmpeg.
    # macOS
    brew install ffmpeg
    
    # Ubuntu/Debian
    sudo apt-get install ffmpeg
  7. Run ShortGPT using Docker

    stable

    To run ShortGPT via Docker, first create a .env file in your project root containing your API keys. Then, build the Docker image and run the container, mapping port 31415 to access the web interface.

    Required environment variables in .env:

    • GEMINI_API_KEY
    • OPENAI_API_KEY
    • ELEVENLABS_API_KEY
    • PEXELS_API_KEY
    # Create .env file
    GEMINI_API_KEY=put_your_gemini_api_key_here
    OPENAI_API_KEY=sk-_put_your_openai_api_key_here
    ELEVENLABS_API_KEY=put_your_eleven_labs_api_key_here
    PEXELS_API_KEY=put_your_pexels_api_key_here
    
    # Build and run Docker
    docker build -t short_gpt_docker:latest .
    docker run -p 31415:31415 --env-file .env short_gpt_docker:latest
    
    # Optional: Export Docker image
    docker save short_gpt_docker > short_gpt_docker.tar
  8. Install and run ShortGPT documentation locally

    stable

    To run the ShortGPT documentation website on your local machine, follow these steps:

    1. Navigate to the root of the repository (two levels above the docs directory) and run yarn install to install dependencies.
    2. Navigate back to the docs directory.
    3. Run yarn start to launch the documentation site. A browser window should open automatically pointing to the documentation.
  9. Use the ContentTranslationEngine to translate video content

    stable

    The ContentTranslationEngine automates video translation by transcribing audio, translating text, generating new audio via a VoiceModule, and rendering the final video.

    To use it, you must provide:

    1. A VoiceModule instance.
    2. A src_url (a local file path or a YouTube/YouTube Shorts link).
    3. A target_language (from the Language enum).
    4. An optional use_captions boolean (set to True to include timed text captions in the output video).

    Workflow:

    • Initialize the engine with the required parameters.
    • Call makeContent() to execute the translation pipeline. This method is a generator that yields step numbers and logs.
    • Call get_video_output_path() to retrieve the location of the rendered video.
    from shortGPT.config.api_db import ApiKeyManager, ApiProvider
    from shortGPT.engine.content_translation_engine import ContentTranslationEngine
    from shortGPT.config.languages import Language
    from shortGPT.audio.edge_voice_module import EdgeTTSVoiceModule, EDGE_TTS_VOICENAME_MAPPING
    
    # Set API Keys
    ApiKeyManager.set_api_key(ApiProvider.OPENAI, "your_openai_key")
    ApiKeyManager.set_api_key(ApiProvider.ELEVEN_LABS, "your_eleven_labs_key")
    
    # Configure the Voice Module
    voice_name = EDGE_TTS_VOICENAME_MAPPING[Language.SPANISH]['male']
    voice_module = EdgeTTSVoiceModule(voice_name)
    
    # Configure Content Engine
    src_url = "https://www.youtube.com/watch?v=QQz5hj8y1TE"
    target_language = Language.SPANISH
    use_captions = False
    content_engine = ContentTranslationEngine(voice_module, src_url, target_language, use_captions)
    
    # Generate Content
    for step_num, step_logs in content_engine.makeContent():
        print(f" {step_logs}")
    
    # Get Video Output Path
    print(content_engine.get_video_output_path())
  10. Install FFmpeg 4.2.3 from source

    stable

    ShortGPT requires FFmpeg version 4.2.3. This guide involves installing build dependencies, cloning the specific n4.2.3 tag from the FFmpeg repository, configuring with specific flags, and compiling.

    # 1. Install Build Dependencies
    sudo apt update
    sudo apt build-dep ffmpeg
    
    # 2. Clone and Checkout version 4.2.3
    git clone https://git.ffmpeg.org/ffmpeg.git
    cd ffmpeg
    git checkout n4.2.3
    
    # 3. Configure
    ./configure --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-avisynth --enable-libopenmpt --enable-shared --disable-static
    
    # 4. Build and Install
    make -j$(nproc)
    sudo make install
    
    # 5. Verify
    ffmpeg -version
    
    # Optional: Update library cache
    sudo ldconfig