Skip to content

aShanki/videocompress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VideoCompress

A high-performance CLI tool for video compression with AMD GPU hardware acceleration support.

Features

  • AMD GPU Acceleration: Utilizes VAAPI for hardware-accelerated H.265 encoding
  • Automatic Fallback: Falls back to software encoding if GPU acceleration fails
  • Batch Processing: Compress multiple videos sequentially
  • Configurable: YAML configuration with quality presets
  • Progress Tracking: Real-time compression progress and statistics
  • File Size Control: Target specific output file sizes

Installation

# Clone and build
git clone <repository>
cd videocompress
go build -o videocompress

# Or install directly
go install

Usage

Basic Usage

# Compress a single video
./videocompress /path/to/video.mp4

# Compress multiple videos
./videocompress /home/User/Videos/test.mp4 /home/User/Videos/test2.mp4 /home/User/Videos/test3.mp4

# Compress with custom target size
./videocompress -s 50M /path/to/video.mp4

# Compress multiple videos sequentially
./videocompress /path/to/videos/*.mp4

Command Line Options

Flags:
  -s, --target-size string    Target file size (e.g., 100M, 50MB) (default from config)
  -c, --container string      Output container format (mp4, mkv, webm) (default from config)
  -q, --quality string        Quality preset (low, medium, high, ultra) (default "medium")
  -o, --output-dir string     Output directory (default: same as input)
      --config string         Path to configuration file
  -h, --help                  help for videocompress

Configuration

Create a config.yaml file in your project directory or ~/.videocompress/config.yaml:

compression:
  target_size: "100M"
  container: "mp4"
  audio_bitrate: "128k"
  quality_presets:
    low: 32
    medium: 26
    high: 20
    ultra: 16

hardware:
  vaapi_device: "/dev/dri/renderD128"
  prefer_gpu: true

output:
  suffix: "_compressed"
  same_directory: true
  directory: ""

ffmpeg:
  path: "ffmpeg"
  threads: 0

Hardware Requirements

AMD GPU Support

  • Required: AMD GPU with HEVC encoding support (RX 5000 series or newer recommended)
  • Drivers: Mesa drivers with VAAPI support
  • System: Linux with proper AMD GPU drivers installed

Software Requirements

  • FFmpeg: Must be installed and available in PATH
  • Go: 1.19+ for building from source

Examples

Compress videos to 100MB each

./videocompress -s 100M /home/User/Videos/*.mp4

High quality compression with multiple videos

./videocompress -q high video1.mp4 video2.mp4 video3.mp4

Custom output directory

./videocompress -o /home/User/compressed/ /home/User/Videos/*.mp4

Architecture

videocompress/
├── cmd/                    # CLI commands and argument parsing
├── internal/
│   ├── config/            # Configuration management
│   ├── compressor/        # Core compression logic
│   ├── queue/             # Job queue and parallel processing
│   └── types/             # Shared type definitions
├── config.yaml           # Default configuration
└── main.go               # Application entry point

Compression Methods

  1. AMD GPU VAAPI (Primary): Hardware-accelerated H.265 encoding
  2. Software H.265 (Fallback): CPU-based encoding using libx265

The tool automatically tries GPU acceleration first and falls back to software encoding if hardware acceleration fails or is unavailable.

Output

The tool provides detailed output including:

  • Real-time compression progress
  • Method used (GPU/Software)
  • File size reduction statistics
  • Processing time per video
  • Summary of successful and failed compressions

Troubleshooting

GPU Acceleration Issues

If GPU acceleration fails:

  1. Verify AMD GPU drivers are properly installed
  2. Check VAAPI device path (/dev/dri/renderD128)
  3. Ensure ffmpeg was compiled with VAAPI support
  4. The tool will automatically fall back to software encoding

Common Issues

  • File not found: Verify input file paths are correct
  • Permission denied: Ensure write permissions in output directory
  • FFmpeg not found: Install ffmpeg and ensure it's in PATH

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages