Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

boiled-darvari/hpc-transcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hpc-transcode

High-performance distributed video transcoding with CPU/GPU support

Codacy Security Scan

Features

  • Distributed transcoding across multiple nodes using SSH
  • CPU and GPU (NVIDIA CUDA) support
  • Multi-resolution output (e.g. 240p, 480p, 720p)
  • Audio track preservation
  • HLS output support
  • Segment-based processing

Usage

Usage: gpff.bash [options]

Options:
  -d | --work-dir <path>          Set working directory (default: /mnt/data/)
  -i | --input <file>             Input file (must be .mkv or .mp4)
  -b | --ffmpeg-bin-dir <path>    Directory containing ffmpeg binaries
  -l | --local-only               Run locally only
  -g | --with-gpu                 Use GPU acceleration
  -r | --resolutions <list>       Comma-separated resolutions (default: 240,480,720)
  -a | --audio-duration <secs>    Audio segment duration (default: 600)
  -v | --video-duration <secs>    Video segment duration (default: 60)
  -s | --hls-duration <secs>      HLS segment duration (default: 10)
  -V | --version                  Show version information
  -h | --help                     Show help message

Examples:
  # Basic distributed CPU transcoding
  gpff.bash -i video.mkv

  # Local CPU transcoding
  gpff.bash -i video.mkv -l

  # Custom resolutions
  gpff.bash -i video.mkv -r 480,720,1080

  # GPU acceleration with SSD path and custom FFmpeg build
  gpff.bash -i "./Akira.1988.mkv" -g -d "/mnt/data/" -b "/mnt/data/ffmpeg-n7.1-latest-linux64-gpl-7.1/bin/ffmpeg/"

Tip: Always run inside tmux for long transcoding jobs inside the servers

Requirements & Setup

Master Node

  1. FFmpeg
    • CPU mode: Any recent build
    • GPU mode: Must have CUDA support (see FFmpeg Setup)
  2. GNU Parallel (Installation Guide)
  3. OpenSSH Client
  4. tmux (recommended)

Worker Nodes

  1. FFmpeg (same version/capabilities as master)
  2. OpenSSH Server
  3. For GPU mode:
    • NVIDIA GPU
    • NVIDIA drivers
    • CUDA Toolkit
    • FFmpeg with CUDA support

FFmpeg Setup

Choose one:

  1. BtbN's FFmpeg Builds (GPL with CUDA)
  2. Custom build with CUDA
  3. Official static builds (verify CUDA support)

⚠️ Package manager versions typically lack CUDA support

Installation Steps

  1. Install base packages:
# Master node (Debian/Ubuntu)
sudo apt install parallel tmux openssh-client   # Debian/Ubuntu

# Worker nodes
sudo apt install openssh-server                 # Debian/Ubuntu

# For GPU in Master and Workers: 
sudo apt install nvidia-cuda-toolkit            # Debian/Ubuntu
sudo dnf install cuda-toolkit                   # RHEL/Fedora
  1. Setup SSH:
ssh-keygen -t ed25519 -C "transcode-cluster"
ssh-copy-id user@worker123
ssh-copy-id resu@1.2.3.4
  1. Configure GNU Parallel (master only):
parallel --will-cite  # Acknowledge citation
echo "user@worker1" >> ~/.parallel/sshloginfile
echo "user@worker2" >> ~/.parallel/sshloginfile
echo "resu@1.2.3.4" >> ~/.parallel/sshloginfile
  1. Prepare storage (all nodes):
sudo mkdir -p /mnt/data
sudo mount /dev/nvme0n1 /mnt/data    # Example for NVMe drive

Verification

Test your setup:

# Basic connectivity
parallel --nonall -S '..' hostname

# FFmpeg availability & version
parallel --nonall -S '..' ffmpeg -version

# GPU support (if using)
parallel --nonall -S '..' '
    if command -v nvidia-smi >/dev/null; then
        echo "=== $(hostname) ==="
        nvidia-smi
        ffmpeg -hide_banner -filters | grep cuda
    fi
'

Advanced Usage

Performance Tuning

# Adjust segment durations
gpff.bash -i video.mkv -a 300 -v 30

# Custom resolutions
gpff.bash -i video.mkv -r 360,720,1080

Output Types

  • Resolution-specific files (MP4/MKV)
  • HLS playlist with all qualities
  • Original container format preserved
  • All audio tracks included

Troubleshooting

  1. GPU Issues

    • Verify CUDA in FFmpeg: ffmpeg -filters | grep cuda
    • Check GPU access: nvidia-smi
    • Confirm matching FFmpeg versions
  2. Node Issues

    • Test SSH access
    • Verify work directory exists
    • Check file permissions
  3. Processing Issues

    • Segment duration adjustments
    • Audio sync (-fps_mode passthrough)
    • Work directory space

Notes

  • This is a proof-of-concept (POC) implementation. Expect potential changes and instability.
  • Tested: FFmpeg n7.1+ (GPL build)
  • Formats: MKV, MP4
  • Subtitles are not handled in this script
Morty Proxy This is a proxified and sanitized view of the page, visit original site.