Skip to content

moonwhaler/VEN

Repository files navigation

VEN - Professional FFmpeg Video Encoder

Rust-based video encoding tool built on FFmpeg and x265/HEVC for batch processing with intelligent content analysis.

Quick Start

# Auto-detect content and encode
./ffmpeg-encoder -i input.mkv

# Specify profile and mode
./ffmpeg-encoder -i input.mkv -p anime -m crf

# Batch process directory
./ffmpeg-encoder -i /path/to/videos/ -p auto

# Strip Dolby Vision metadata (fast, no re-encode)
./ffmpeg-encoder -i input.mkv --strip-dolby-vision

Key Features

  • Three encoding modes: CRF (quality), ABR (average bitrate), CBR (constant bitrate)
  • HDR support: Dolby Vision (profiles 5, 7, 8.1, 8.2, 8.4) and HDR10+ with metadata preservation
  • Metadata stripping: Fast removal of Dolby Vision or HDR10+ metadata without re-encoding (copy mode)
  • Auto crop detection: Multi-sample temporal analysis with HDR/SDR-specific thresholds
  • Stream preservation: Losslessly copies all audio, subtitles, chapters, and metadata
  • 11 content-specific profiles: From anime to heavy grain 4K content
  • Preview mode: Test encoding settings on frames or segments before full encode
  • Processing filters: NNEDI3/yadif deinterlacing, hqdn3d denoising

Installation

Requirements:

  • Rust 1.70+ with Cargo
  • FFmpeg with libx265 support
  • Optional: dovi_tool (Dolby Vision), hdr10plus_tool (HDR10+), mkvmerge (from mkvtoolnix)

Quick Build

Linux/macOS:

git clone https://github.com/user/ffmpeg_autoencoder_rust.git
cd ffmpeg_autoencoder_rust

# Production build (optimized, recommended)
./build.sh production

# Or development build (faster compile, includes debug symbols)
./build.sh dev

Windows:

git clone https://github.com/user/ffmpeg_autoencoder_rust.git
cd ffmpeg_autoencoder_rust

REM Production build (optimized, recommended)
build.bat production

REM Or development build (faster compile, includes debug symbols)
build.bat dev

Manual build (all platforms):

# Production build
cargo build --release
# Binary: target/release/ffmpeg-encoder

# Development build
cargo build
# Binary: target/debug/ffmpeg-encoder

The build scripts will check for required dependencies and provide helpful error messages if anything is missing.

Usage

Basic Commands

# Auto mode (detects best profile)
./ffmpeg-encoder -i input.mkv

# Specific profile
./ffmpeg-encoder -i input.mkv -p anime -m crf

# Batch processing
./ffmpeg-encoder -i /videos/ -p auto

# Custom output path
./ffmpeg-encoder -i input.mkv -o /output/path.mkv

Preview Mode

Test encoding settings before processing the full file. Simply use --preview-time or --preview-range to automatically enter preview mode:

# Generate single frame preview image at 60s
./ffmpeg-encoder -i input.mkv -p anime --preview-time 60

# Generate 10-second video segment preview (30s-40s)
./ffmpeg-encoder -i input.mkv -p anime --preview-range 30-40

# Compare multiple profiles with a preview profile group
./ffmpeg-encoder -i input.mkv --preview-time 60 --preview-profile anime_comparison

Preview options:

  • --preview-time <SECONDS> - Generate a single frame image at the specified timestamp
  • --preview-range <START-END> - Generate a video segment from start to end time (e.g., "30-40")
  • --preview-profile <NAME> - Test multiple encoding profiles simultaneously for comparison

Preview outputs are saved as {UUID}_preview_{profile}_{timestamp}.{ext} in the same directory as the input file.

Metadata Stripping (Fast Copy Mode)

Strip Dolby Vision or HDR10+ metadata without re-encoding. This operation is very fast (seconds instead of hours) as it simply copies all streams and removes the specified metadata:

# Strip Dolby Vision metadata (keeps base HDR10)
./ffmpeg-encoder -i "Dolby Vision Movie.mkv" --strip-dolby-vision

# Strip HDR10+ dynamic metadata (keeps base HDR10)
./ffmpeg-encoder -i "HDR10+ Movie.mkv" --strip-hdr10-plus

# With custom output
./ffmpeg-encoder -i input.mkv --strip-dolby-vision -o output.mkv

# Batch process entire directory
./ffmpeg-encoder -i /movies/ --strip-dolby-vision

What gets stripped:

  • --strip-dolby-vision: Removes Dolby Vision RPU data and configuration records
  • --strip-hdr10-plus: Removes HDR10+ dynamic metadata (SEI messages)

What gets preserved:

  • Base HDR10 static metadata (master display, max content light level)
  • All video streams (copied, not re-encoded)
  • All audio streams
  • All subtitle streams
  • Chapters and attachments

Note: You cannot use both flags simultaneously - choose one based on your source content.

Processing Filters

# Legacy interlaced content
./ffmpeg-encoder -i old_dvd.avi --deinterlace -p classic_anime

# Heavy grain with denoising
./ffmpeg-encoder -i grainy_film.mkv --denoise -p heavy_grain

# CBR for streaming
./ffmpeg-encoder -i input.mkv -p movie -m cbr

Profiles

View available profiles:

./ffmpeg-encoder --list-profiles
./ffmpeg-encoder --show-profile anime

Content-optimized profiles:

  • movie, movie_mid_grain, movie_size_focused - Live-action films
  • heavy_grain - High-grain preservation
  • anime, classic_anime - 2D animation
  • 3d_cgi, 3d_complex - 3D animated content
  • 4k, 4k_heavy_grain - 4K content
  • auto - Automatic profile selection

Stream Selection

Control which audio/subtitle streams to include:

# English only
./ffmpeg-encoder -i input.mkv -s english_only

# Multiple languages
./ffmpeg-encoder -i input.mkv -s multilang

# View available profiles
./ffmpeg-encoder --list-stream-profiles

Configuration

The app automatically searches for config.yaml in this order:

  1. Path specified via --config (if provided)
  2. config/ subdirectory next to the binary
  3. User config directory: ~/.config/ffmpeg-encoder/ (Linux), ~/Library/Application Support/ffmpeg-encoder/ (macOS), %APPDATA%\ffmpeg-encoder\ (Windows)
  4. Falls back to embedded default configuration

Key settings:

  • Tool paths: FFmpeg, FFprobe, dovi_tool, hdr10plus_tool, mkvmerge
  • Analysis: Crop detection thresholds, HDR/Dolby Vision handling
  • Filters: Deinterlacing (NNEDI3/yadif), denoising (hqdn3d)
  • Profiles: Custom encoding profiles with x265 parameters
  • Preview profiles: Define comparison groups for preview mode
  • Stream selection: Audio/subtitle filtering rules

Validate your config:

./ffmpeg-encoder --validate-config

HDR & Dolby Vision

The tool automatically detects and handles HDR content:

  • HDR10: Preserves static HDR metadata
  • HDR10+: Extracts and re-injects dynamic metadata using hdr10plus_tool
  • Dolby Vision: Converts profiles for compatibility (e.g., Profile 7 → 8.1), preserves RPU data using dovi_tool

All HDR processing is automatic - just encode as normal. The tool applies appropriate bitrate and CRF adjustments per profile.

Output

File naming:

  • Auto-generated: {original_filename}_{UUID}.{ext} (prevents conflicts, preserves original name)
  • Custom: Use -o flag
  • Logs: {original_filename}_{UUID}.log with detailed encoding information

Progress display: Real-time progress bar with FPS, speed, ETA, and file size estimates.

Help

# List available profiles
./ffmpeg-encoder --list-profiles

# Show profile details
./ffmpeg-encoder --show-profile anime

# Validate configuration
./ffmpeg-encoder --validate-config

# View all available options
./ffmpeg-encoder --help

Advanced Usage

Custom configuration:

./ffmpeg-encoder --config /path/to/custom.yaml -i input.mkv

Logging:

# Verbose output
./ffmpeg-encoder -i input.mkv -v

# Debug output
./ffmpeg-encoder -i input.mkv --debug

Technical Details

Architecture:

  • Async I/O with Tokio
  • Type-safe configuration (Serde YAML)
  • Multi-pass encoding for ABR/CBR
  • Unified content analysis pipeline
  • Comprehensive error handling with context

Processing pipeline:

  1. Content analysis (resolution, HDR detection, crop detection)
  2. Profile selection (auto or manual)
  3. Stream mapping (audio/subtitle filtering)
  4. Encoding (CRF/ABR/CBR with x265)
  5. HDR metadata processing (Dolby Vision/HDR10+)
  6. Output verification and logging

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published