foxws / laravel-ab-av1
A Laravel package for encoding videos to AV1 format using ab-av1.
Fund package maintenance!
Foxws
Installs: 268
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/foxws/laravel-ab-av1
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
A Laravel wrapper for ab-av1, the AV1 video encoder with automatic CRF calculation and VMAF quality targeting.
Features
- Automatic CRF Discovery: Find the optimal CRF value to achieve target VMAF quality
- Multiple Encoders: Support for av1_svtenc, av1_vaapi, libx264, libx265, and other ffmpeg encoders
- Quick Sampling: Test encode quality before full encoding
- Hardware Acceleration: Support for VAAPI and other hardware acceleration methods
- VMAF/XPSNR Comparison: Calculate quality scores between original and encoded files
- Event Dispatching: Listen to encoding events (started, completed, failed)
- Fluent Interface: Chainable configuration API
Installation
Ensure ab-av1 is installed:
# macOS brew install ab-av1 # Linux (Arch) sudo pacman -S ab-av1
Install the Laravel package:
composer require foxws/laravel-ab-av1
Publish the config:
php artisan vendor:publish --provider="Foxws\AbAv1\AbAv1ServiceProvider"
Configuration
Binary Path
By default, the package expects ab-av1 to be in your system PATH. If you need to use a specific binary path or version, configure it in config/ab-av1.php or via environment variable:
# .env AB_AV1_BINARY=/usr/local/bin/ab-av1 # Or use a specific cargo installation AB_AV1_BINARY=/home/user/.cargo/bin/ab-av1
Verify your installation:
php artisan ab-av1:info
Quick Start
use Foxws\AbAv1\Facades\AbAv1; $result = AbAv1::encode() ->withInput('/path/to/video.mp4') ->withPreset('medium') ->withMinVMAF(95) ->autoEncode(); echo "VMAF: {$result->getVMAFScore()}"; echo "CRF: {$result->getCRFUsed()}";
Usage Examples
Auto-encode (Recommended)
Automatically find the best CRF for your target VMAF quality:
$result = AbAv1::encode() ->withInput('video.mp4') ->withPreset('medium') ->withMinVMAF(95) ->withOutput('output.mp4') ->autoEncode();
Direct Encode
Encode with a specific CRF value:
$result = AbAv1::encode() ->withInput('video.mp4') ->withCRF(30) ->withPreset('slow') ->encode();
Sample Encode
Quick test to preview quality:
$result = AbAv1::encode() ->withInput('video.mp4') ->withCRF(28) ->sampleEncode();
Hardware Acceleration
Enable VAAPI for faster encoding:
$result = AbAv1::encode() ->withInput('video.mp4') ->withPreset('medium') ->withMinVMAF(95) ->withFFmpegOptions([ 'hwaccel' => 'vaapi', 'hwaccel_output_format' => 'vaapi', ]) ->autoEncode();
Testing
composer test
Documentation
See examples/basic-usage.php for comprehensive usage examples.
For detailed documentation, see the generated docs.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- francoism90
- All Contributors
- Inspired by ab-av1
License
The MIT License (MIT). Please see License File for more information.