1. Go to this page and download the library: Download foxws/laravel-av1 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
foxws / laravel-av1 example snippets
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');
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');
// 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');
use Foxws\AV1\Facades\AV1;
$result = AV1::open('input.mp4')
->abav1() // Use ab-av1 encoder
->vmafEncode()
->preset('6')
->minVmaf(95)
->export()
->save('output.mp4');
use Foxws\AV1\Facades\AV1;
$result = AV1::open('input.mp4')
->abav1() // Use ab-av1 encoder
->vmafEncode()
->preset('6')
->minVmaf(95)
->export()
->save('output.mp4');
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');
}
$result = AV1::open('input.mp4')
->abav1()
->crfSearch()
->preset('6')
->minVmaf(95)
->export()
->save();
// The output will contain the recommended CRF value
echo $result->getOutput();