PHPackages                             foxws/laravel-av1 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. foxws/laravel-av1

Abandoned → [foxws/laravel-ab-av1](/?search=foxws%2Flaravel-ab-av1)ArchivedLibrary[Image &amp; Media](/categories/media)

foxws/laravel-av1
=================

A Laravel package for ab-av1 video encoding with AV1

0.5.0(5mo ago)1414MITPHPPHP ^8.3 || ^8.4 || ^8.5CI passing

Since Jan 23Pushed 5mo agoCompare

[ Source](https://github.com/foxws/laravel-av1)[ Packagist](https://packagist.org/packages/foxws/laravel-av1)[ Docs](https://github.com/foxws/laravel-av1)[ GitHub Sponsors](https://github.com/foxws)[ RSS](/packages/foxws-laravel-av1/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (16)Versions (7)Used By (0)

Laravel AV1
===========

[](#laravel-av1)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5bf37d3afe08e147df339769c9550abd878e247fb4570a5a5946baa5172b68d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f7877732f6c61726176656c2d6176312e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxws/laravel-av1)[![Tests](https://camo.githubusercontent.com/5e4c86e9fdecf0d517ce1e4f7494e35275a66c54fd5c517699fd343e410116c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f666f7877732f6c61726176656c2d6176312f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/foxws/laravel-av1/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/e5d1ae8f448971a728817c53e0cd6e11f8a66e16a05e33513132efa90b7d450b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666f7877732f6c61726176656c2d6176312e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxws/laravel-av1)

A Laravel package for AV1 video encoding with support for [ab-av1](https://github.com/alexheretic/ab-av1) VMAF-targeted quality optimization and direct FFmpeg encoding with hardware acceleration (Intel QSV, AMD AMF, NVIDIA NVENC).

```
use Foxws\AV1\Facades\AV1;

// FFmpeg encoding with hardware acceleration
$result = AV1::open('videos/input.mp4')
    ->ffmpegEncode()
    ->useHardwareAcceleration()
    ->crf(28)
    ->preset('6')
    ->export()
    ->toDisk('s3')
    ->save('output.mp4');

// Or use ab-av1 for VMAF-targeted encoding
$result = AV1::open('videos/input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->save('output.mp4');
```

Features
--------

[](#features)

- 🎬 **Fluent API** - Laravel-style chainable methods
- 📁 **Multiple Disks** - Works with local, S3, and custom filesystems
- 🎯 **VMAF-Targeted Encoding** - Automatically finds optimal CRF for target quality using ab-av1
- ⚡ **Hardware Acceleration** - GPU encoding support (Intel QSV, AMD AMF, NVIDIA NVENC)
- 🔄 **Multiple Encoders** - Support for ab-av1 and FFmpeg with auto-detection
- 📊 **Quality Metrics** - Built-in VMAF &amp; XPSNR scoring
- 🚀 **Auto CRF Optimization** - Use ab-av1 to find optimal CRF, then encode with FFmpeg GPU
- 🧪 **Testable** - Clean architecture with mockable components
- 📝 **Type-Safe** - Full PHP 8.4+ type declarations

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.x or higher
- FFmpeg with AV1 encoder support (libsvtav1 or hardware encoder)
- Optional: [ab-av1](https://github.com/alexheretic/ab-av1) for VMAF-targeted quality optimization

Installation
------------

[](#installation)

Install the package via composer:

```
composer require foxws/laravel-av1
```

Publish the config file:

```
php artisan vendor:publish --tag="av1-config"
```

### Installing ab-av1 (Optional)

[](#installing-ab-av1-optional)

ab-av1 is optional but recommended for VMAF-targeted quality optimization. Install using cargo:

```
cargo install ab-av1
```

Or download a prebuilt binary from the [releases page](https://github.com/alexheretic/ab-av1/releases).

### Installing FFmpeg with AV1 Support

[](#installing-ffmpeg-with-av1-support)

FFmpeg is required for direct AV1 encoding. Ensure FFmpeg is compiled with AV1 encoder support:

```
# Check available AV1 encoders
ffmpeg -encoders | grep av1

# You should see one or more of:
# - libsvtav1 (CPU encoding)
# - av1_qsv (Intel Quick Sync)
# - av1_amf (AMD)
# - av1_nvenc (NVIDIA)
```

For hardware acceleration support, you'll need FFmpeg compiled with the appropriate hardware encoder for your GPU.

### Verify Installation

[](#verify-installation)

After installation, verify that ab-av1 is properly configured:

```
php artisan av1:verify
```

This will check:

- Binary exists and is executable
- Can retrieve version information
- Configuration is properly set up
- Temporary directory is accessible

### Package Information

[](#package-information)

View package and binary information:

```
php artisan av1:info
```

Quick Start
-----------

[](#quick-start)

### FFmpeg Hardware Encoding

[](#ffmpeg-hardware-encoding)

Encode videos using FFmpeg with automatic hardware acceleration detection:

```
use Foxws\AV1\Facades\AV1;

// Auto-detect and use GPU acceleration
$result = AV1::open('input.mp4')
    ->ffmpegEncode()
    ->useHardwareAcceleration()
    ->crf(28)
    ->preset('6')
    ->export()
    ->save('output.mp4');
```

### FFmpeg with Auto CRF Optimization

[](#ffmpeg-with-auto-crf-optimization)

Combine ab-av1's CRF optimization with FFmpeg's GPU encoding:

```
// Use ab-av1 to find optimal CRF, then encode with FFmpeg GPU
$result = AV1::open('input.mp4')
    ->ffmpegAutoEncode()
    ->targetVmaf(95)
    ->preset('6')
    ->useHardwareAcceleration()
    ->export()
    ->save('output.mp4');
```

### Using ab-av1 Encoder

[](#using-ab-av1-encoder)

Use ab-av1 for integrated VMAF-targeted encoding:

```
use Foxws\AV1\Facades\AV1;

$result = AV1::open('input.mp4')
    ->abav1() // Use ab-av1 encoder
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->save('output.mp4');
```

### VMAF Encode

[](#vmaf-encode)

Automatically find the optimal CRF value to achieve a target VMAF quality score and encode the full video:

```
use Foxws\AV1\Facades\AV1;

$result = AV1::open('input.mp4')
    ->abav1() // Use ab-av1 encoder
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->save('output.mp4');
```

### Hardware Acceleration

[](#hardware-acceleration)

Check available hardware encoders and use the best available:

```
use Foxws\AV1\FFmpeg\HardwareDetector;

$detector = new HardwareDetector();

// Check available encoders
$encoders = $detector->getAvailableEncoders();
// ['av1_qsv' => [...], 'libsvtav1' => [...]]

// Check if hardware acceleration is available
if ($detector->hasHardwareAcceleration()) {
    $result = AV1::open('input.mp4')
        ->ffmpegEncode()
        ->useHardwareAcceleration()
        ->crf(28)
        ->export()
        ->save('output.mp4');
}
```

### CRF Search (ab-av1)

[](#crf-search-ab-av1)

Search for the optimal CRF value without encoding the full video:

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->crfSearch()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->save();

// The output will contain the recommended CRF value
echo $result->getOutput();
```

### Sample Encode (ab-av1)

[](#sample-encode-ab-av1)

Encode a sample of the video to test settings:

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->sampleEncode()
    ->crf(30)
    ->preset('6')
    ->sample(60) // Sample duration in seconds
    ->export()
    ->save('sample.mp4');
```

### Full Encode (ab-av1)

[](#full-encode-ab-av1)

Encode the entire video with a specific CRF:

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->encode()
    ->crf(30)
    ->preset('6')
    ->export()
    ->save('output.mp4');
```

### VMAF Score

[](#vmaf-score)

Calculate VMAF score between two videos:

```
$result = AV1::vmaf()
    ->abav1()
    ->reference('original.mp4')
    ->distorted('encoded.mp4')
    ->export()
    ->save();

echo $result->getOutput(); // VMAF score
```

### XPSNR Score

[](#xpsnr-score)

Calculate XPSNR score between two videos:

```
$result = AV1::xpsnr()
    ->abav1()
    ->reference('original.mp4')
    ->distorted('encoded.mp4')
    ->export()
    ->save();

echo $result->getOutput(); // XPSNR score
```

FFmpeg Encoding
---------------

[](#ffmpeg-encoding)

### Basic FFmpeg Encoding

[](#basic-ffmpeg-encoding)

```
// Simple FFmpeg encode
$result = AV1::open('input.mp4')
    ->ffmpegEncode()
    ->crf(28)
    ->preset('6')
    ->export()
    ->save('output.mp4');

// With 10-bit color
$result = AV1::open('input.mp4')
    ->ffmpegEncode()
    ->crf(28)
    ->pixFmt('yuv420p10le')
    ->export()
    ->save('output.mp4');
```

### GPU Acceleration

[](#gpu-acceleration)

```
// Auto-detect and use best hardware encoder
$result = AV1::open('input.mp4')
    ->ffmpegEncode()
    ->useHardwareAcceleration()
    ->crf(28)
    ->preset('6')
    ->export()
    ->save('output.mp4');
```

### Auto CRF with FFmpeg

[](#auto-crf-with-ffmpeg)

Combine ab-av1's CRF optimization with FFmpeg's GPU encoding:

```
// Find optimal CRF with ab-av1, encode with FFmpeg GPU
$result = AV1::open('input.mp4')
    ->ffmpegAutoEncode()
    ->targetVmaf(95)
    ->preset('6')
    ->useHardwareAcceleration()
    ->export()
    ->save('output.mp4');
```

For detailed FFmpeg examples including hardware-specific configurations, see [FFMPEG\_ENCODING.md](FFMPEG_ENCODING.md).

Working with Different Disks
----------------------------

[](#working-with-different-disks)

### From S3

[](#from-s3)

```
$result = AV1::fromDisk('s3')
    ->open('videos/input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->toDisk('s3')
    ->save('videos/output.mp4');
```

### From Local to S3

[](#from-local-to-s3)

```
$result = AV1::open('local/input.mp4')
    ->abav1()
    ->encode()
    ->crf(30)
    ->preset('6')
    ->export()
    ->toDisk('s3')
    ->toPath('videos/encoded')
    ->save('output.mp4');
```

### S3 with Hardware Encoding

[](#s3-with-hardware-encoding)

```
$result = AV1::fromDisk('s3')
    ->open('videos/input.mp4')
    ->ffmpegEncode()
    ->useHardwareAcceleration()
    ->crf(28)
    ->export()
    ->toDisk('s3')
    ->save('encoded/output.mp4');
```

Advanced Options
----------------

[](#advanced-options)

### CRF Range

[](#crf-range)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->crfSearch()
    ->minCrf(20)
    ->maxCrf(40)
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->save();
```

### Max Encoded Size

[](#max-encoded-size)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->maxEncodedPercent(95) // Max 95% of original size
    ->export()
    ->save('output.mp4');
```

### Pixel Format

[](#pixel-format)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->encode()
    ->crf(30)
    ->preset('6')
    ->pixFmt('yuv420p10le')
    ->export()
    ->save('output.mp4');
```

### Full VMAF

[](#full-vmaf)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->fullVmaf() // Calculate VMAF for entire video
    ->export()
    ->save('output.mp4');
```

### VMAF Model

[](#vmaf-model)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->vmafModel('/path/to/vmaf_model.json')
    ->export()
    ->save('output.mp4');
```

### Verbose Output

[](#verbose-output)

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->verbose()
    ->export()
    ->save('output.mp4');

echo $result->getOutput();
```

Batch Processing
----------------

[](#batch-processing)

Process multiple files:

```
$files = ['video1.mp4', 'video2.mp4', 'video3.mp4'];

AV1::fromDisk('s3')
    ->each($files, function ($av1, $file) {
        $av1->open($file)
            ->abav1()
            ->vmafEncode()
            ->preset('6')
            ->minVmaf(95)
            ->export()
            ->toDisk('s3')
            ->toPath('encoded')
            ->save();
    });
```

Callbacks
---------

[](#callbacks)

Add callbacks after encoding:

```
$result = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->afterSaving(function ($result, $path) {
        Log::info("Encoded to: {$path}");
        Log::info("VMAF score: {$result->getOutput()}");
    })
    ->save('output.mp4');
```

Debugging
---------

[](#debugging)

Get the command that will be executed:

```
$command = AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->getCommand();

echo $command;
// Output: ab-av1 auto-encode -i input.mp4 --preset 6 --min-vmaf 95
```

Or dump and die:

```
AV1::open('input.mp4')
    ->abav1()
    ->vmafEncode()
    ->preset('6')
    ->minVmaf(95)
    ->export()
    ->dd();
```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

**ab-av1 Configuration:**

- `AB_AV1_BINARY_PATH` - Path to ab-av1 binary (default: '/usr/local/bin/ab-av1')
- `AB_AV1_TIMEOUT` - Maximum time in seconds for encoding commands (default: 14400)
- `AB_AV1_PRESET` - Default encoder preset 0-13 for svt-av1 (default: 6)
- `AB_AV1_MIN_VMAF` - Minimum VMAF score to target (default: 80)
- `AB_AV1_MAX_PERCENT` - Maximum encoded file size as percentage (default: 300)

**FFmpeg Configuration:**

- `FFMPEG_BINARY_PATH` - Path to ffmpeg binary (default: '/usr/local/bin/ffmpeg')
- `FFMPEG_TIMEOUT` - Maximum time in seconds for FFmpeg encoding (default: 7200)
- `FFMPEG_ENCODER` - Force specific encoder (null = auto-detect): av1\_qsv, av1\_amf, av1\_nvenc, libsvtav1
- `FFMPEG_HARDWARE_ACCEL` - Enable hardware acceleration (default: true)
- `FFMPEG_DEFAULT_CRF` - Default CRF value (default: 30)
- `FFMPEG_DEFAULT_PRESET` - Default preset (default: 6)
- `FFMPEG_AUDIO_CODEC` - Default audio codec (default: 'libopus')
- `FFMPEG_PIXEL_FORMAT` - Default pixel format (default: 'yuv420p')
- `FFMPEG_AUTO_CRF` - Use ab-av1 for auto CRF by default (default: false)

**General:**

- `AB_AV1_LOG_CHANNEL` - Log channel to use (false to disable, null for default)
- `AB_AV1_TEMPORARY_FILES_ROOT` - Directory for temporary files (default: storage/app/av1/temp)

### Configuration File

[](#configuration-file)

Publish and edit `config/av1.php` for more control:

```
return [
    'binaries' => [
        'ab-av1' => env('AB_AV1_BINARY_PATH', '/usr/local/bin/ab-av1'),
        'ffmpeg' => env('FFMPEG_BINARY_PATH', '/usr/local/bin/ffmpeg'),
    ],

    'ffmpeg' => [
        'timeout' => env('FFMPEG_TIMEOUT', 7200),
        'encoder' => env('FFMPEG_ENCODER', null),
        'hardware_acceleration' => env('FFMPEG_HARDWARE_ACCEL', true),
        'default_crf' => env('FFMPEG_DEFAULT_CRF', 30),
        'default_preset' => env('FFMPEG_DEFAULT_PRESET', 6),
        'audio_codec' => env('FFMPEG_AUDIO_CODEC', 'libopus'),
        'pixel_format' => env('FFMPEG_PIXEL_FORMAT', 'yuv420p'),
        'auto_crf' => env('FFMPEG_AUTO_CRF', false),
    ],

    'ab-av1' => [
        'timeout' => env('AB_AV1_TIMEOUT', 14400),
        'preset' => env('AB_AV1_PRESET', 6),
        'min_vmaf' => env('AB_AV1_MIN_VMAF', 80),
        'max_encoded_percent' => env('AB_AV1_MAX_PERCENT', 300),
    ],
];
```

Error Handling
--------------

[](#error-handling)

```
try {
    $result = AV1::open('input.mp4')
        ->abav1()
        ->vmafEncode()
        ->preset('6')
        ->minVmaf(95)
        ->export()
        ->save('output.mp4');

    if ($result->isSuccessful()) {
        echo "Encoding successful!";
    } else {
        echo "Encoding failed: " . $result->getErrorOutput();
    }
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

Available Commands
------------------

[](#available-commands)

### vmafEncode()

[](#vmafencode)

Automatically finds the optimal CRF value to achieve a target VMAF score, then encodes the full video at that quality level.

**Required options:**

- `preset(string)` - Encoder preset
- `minVmaf(float)` - Minimum VMAF score

**Optional:**

- `maxEncodedPercent(int)` - Max size as percentage of input
- `sample(int)` - Sample duration in seconds
- `minCrf(int)` - Minimum CRF to try
- `maxCrf(int)` - Maximum CRF to try

### crfSearch()

[](#crfsearch)

Searches for the optimal CRF value to achieve a target VMAF score without encoding the full video. Useful for testing before full encoding.

**Required options:**

- `preset(string)` - Encoder preset (0-13 for svt-av1)
- `minVmaf(float)` - Target VMAF score (0-100)

**Optional:** Same as vmafEncode()

### sampleEncode()

[](#sampleencode)

Encodes a sample portion of the video for testing settings before committing to a full encode.

**Required options:**

- `crf(int)` - CRF value to use for encoding
- `preset(string)` - Encoder preset (0-13 for svt-av1)

**Optional:**

- `sample(int)` - Sample duration in seconds (default varies by encoder)

### encode()

[](#encode)

Encodes the entire video using a manually specified CRF value. Use this when you know the exact CRF you want.

**Required options:**

- `crf(int)` - CRF value (lower = higher quality, larger file)
- `preset(string)` - Encoder preset (0-13 for svt-av1, higher = faster/larger)

### vmaf()

[](#vmaf)

Calculates the VMAF (Video Multimethod Assessment Fusion) quality score between a reference and distorted video.

**Required options:**

- `reference(string)` - Reference (original) video path
- `distorted(string)` - Distorted (encoded) video path

**Optional:**

- `vmafModel(string)` - Path to custom VMAF model file

### xpsnr()

[](#xpsnr)

Calculates the XPSNR (Extended Peak Signal-to-Noise Ratio) quality score between a reference and distorted video.

**Required options:**

- `reference(string)` - Reference (original) video path
- `distorted(string)` - Distorted (encoded) video path

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [ab-av1](https://github.com/alexheretic/ab-av1) - The underlying encoding tool

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance72

Regular maintenance activity

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

156d ago

PHP version history (4 changes)0.1.0PHP ^8.3||^8.4||^8.5

0.3.0PHP ^8.2||^8.3||^8.4

0.4.0PHP ^8.2

0.5.0PHP ^8.3 || ^8.4 || ^8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5028905?v=4)[François M.](/maintainers/francoism90)[@francoism90](https://github.com/francoism90)

---

Top Contributors

[![francoism90](https://avatars.githubusercontent.com/u/5028905?v=4)](https://github.com/francoism90 "francoism90 (50 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

ab-av1av1encodelaraveltranscodelaravelcompressionencodingvideoencoderav1ab-av1vmaf

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/foxws-laravel-av1/health.svg)

```
[![Health](https://phpackages.com/badges/foxws-laravel-av1/health.svg)](https://phpackages.com/packages/foxws-laravel-av1)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[illuminate/view

The Illuminate View package.

13047.0M2.2k](/packages/illuminate-view)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
