Description
This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files
Convert an audio or video file:
FFMpeg::fromDisk('songs') ->open('yesterday.mp3') ->export() ->toDisk('converted_songs') ->inFormat(new \FFMpeg\Format\Audio\Aac) ->save('yesterday.aac');
Instead of the fromDisk() method you can also use the fromFilesystem() method, where $filesystem is an instance of Illuminate\Contracts\Filesystem\Filesystem.
$media = FFMpeg::fromFilesystem($filesystem)->open('yesterday.mp3');
Progress monitoring
You can monitor the transcoding progress. Use the onProgress method to provide a callback, which gives you the completed percentage. In previous versions of this package you had to pass the callback to the format object.
FFMpeg::open('steve_howe.mp4') ->export() ->onProgress(function ($percentage) { echo "{$percentage}% transcoded"; });
The callback may also expose $remaining (in seconds) and $rate:
FFMpeg::open('steve_howe.mp4') ->export() ->onProgress(function ($percentage, $remaining, $rate) { echo "{$remaining} seconds left at rate: {$rate}"; });
Recent Courses on Laravel Daily
[NEW] NativePHP Mobile v4 with SuperNative: Mini-Course
5 lessons
18 min
Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Testing in Laravel 13 For Beginners
26 lessons
1 h 41 min read