PHPackages                             lambq/laravel-ffmpeg - 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. lambq/laravel-ffmpeg

ActiveLibrary

lambq/laravel-ffmpeg
====================

FFMpeg for Laravel

0.0.1(1y ago)07MITPHPPHP ^7.4

Since Feb 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/lambq/laravel-ffmpeg)[ Packagist](https://packagist.org/packages/lambq/laravel-ffmpeg)[ Docs](https://github.com/lambq/laravel-ffmpeg)[ RSS](/packages/lambq-laravel-ffmpeg/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

Laravel FFMpeg
==============

[](#laravel-ffmpeg)

[![Latest Version on Packagist](https://camo.githubusercontent.com/72793a92780133aa669fc1c4f8872e04fba9a79c9f8b129a5a701d1069323559/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70626d656469612f6c61726176656c2d66666d7065672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pbmedia/laravel-ffmpeg)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/033e6a79ae5451523037d336cb1598e04bf0e9fb9d1552b5dc7a5ec0bda0bcce/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70617363616c62616c6a65746d656469612f6c61726176656c2d66666d7065672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/pascalbaljetmedia/laravel-ffmpeg)[![Quality Score](https://camo.githubusercontent.com/727eda58dab66d37cb31d76f602892aff672d1f7149d1b4db2b4a3095d739edc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70617363616c62616c6a65746d656469612f6c61726176656c2d66666d7065672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/pascalbaljetmedia/laravel-ffmpeg)[![Total Downloads](https://camo.githubusercontent.com/a82d9ad3fcb0823af3b2bc320441070e0115feb73e6577c8c736c5db4f154510/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70626d656469612f6c61726176656c2d66666d7065672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pbmedia/laravel-ffmpeg)

This package provides an integration with FFmpeg for Laravel 6.0. The storage of the files is handled by [Laravel's Filesystem](http://laravel.com/docs/6.0/filesystem).

Features
--------

[](#features)

- Super easy wrapper around [PHP-FFMpeg](https://github.com/PHP-FFMpeg/PHP-FFMpeg), including support for filters and other advanced features.
- Integration with [Laravel's Filesystem](http://laravel.com/docs/6.0/filesystem), [configuration system](https://laravel.com/docs/6.0/configuration) and [logging handling](https://laravel.com/docs/6.0/errors).
- Compatible with Laravel 6.0.
- Support for [Package Discovery](https://laravel.com/docs/6.0/packages#package-discovery).
- PHP 7.2 and 7.3 only.

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

[](#installation)

Only the master branch and version 5.0 of this package are compatible with Laravel 6.0. If you're still using an older version of Laravel (or PHP &lt; 7.2), please use the chart below to find out which version you should use. Mind that older versions are no longer supported.

Laravel VersionPackage Version6.05.05.84.05.73.05.62.15.1-5.51.3You can install the package via composer:

```
composer require lambq/laravel-ffmpeg
```

Add the Service Provider and Facade to your `app.php` config file if you're not using Package Discovery.

```
// Laravel 5: config/app.php

'providers' => [
    ...
    Lambq\LaravelFfmpeg\FFMpegServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'FFMpeg' => Lambq\LaravelFfmpeg\Facades\FFMpeg::class
    ...
];
```

Publish the config file using the artisan CLI tool:

```
php artisan vendor:publish --provider="Lambq\LaravelFfmpeg\FFMpegServiceProvider"
```

Usage
-----

[](#usage)

Convert an audio or video file:

```
use Lambq\LaravelFfmpeg\Facades\FFMpeg;

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');
```

You can add filters through a `Closure` or by using PHP-FFMpeg's Filter objects:

```
FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->addFilter(function ($filters) {
        $filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
    })
    ->export()
    ->toDisk('converted_videos')
    ->inFormat(new \FFMpeg\Format\Video\X264)
    ->save('small_steve.mkv');

// or

$start = \FFMpeg\Coordinate\TimeCode::fromSeconds(5)
$clipFilter = new \FFMpeg\Filters\Video\ClipFilter($start);

FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->addFilter($clipFilter)
    ->export()
    ->toDisk('converted_videos')
    ->inFormat(new \FFMpeg\Format\Video\X264)
    ->save('short_steve.mkv');
```

Sometimes you don't want to use the built-in filters. You can apply your own filter by providing a set of options. This can be an array or multiple strings as arguments:

```
FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->addFilter(['-itsoffset', 1]);

// or

FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->addFilter('-itsoffset', 1);
```

Chain multiple convertions:

```
// The 'fromDisk()' method is not required, the file will now
// be opened from the default 'disk', as specified in
// the config file.

FFMpeg::open('my_movie.mov')

    // export to FTP, converted in WMV
    ->export()
    ->toDisk('ftp')
    ->inFormat(new \FFMpeg\Format\Video\WMV)
    ->save('my_movie.wmv')

    // export to Amazon S3, converted in X264
    ->export()
    ->toDisk('s3')
    ->inFormat(new \FFMpeg\Format\Video\X264)
    ->save('my_movie.mkv');

    // you could even discard the 'toDisk()' method,
    // now the converted file will be saved to
    // the same disk as the source!
    ->export()
    ->inFormat(new FFMpeg\Format\Video\WebM)
    ->save('my_movie.webm')

    // optionally you could set the visibility
    // of the exported file
    ->export()
    ->inFormat(new FFMpeg\Format\Video\WebM)
    ->withVisibility('public')
    ->save('my_movie.webm')
```

Create a frame from a video:

```
FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->getFrameFromSeconds(10)
    ->export()
    ->toDisk('thumnails')
    ->save('FrameAt10sec.png');

// Instead of the 'getFrameFromSeconds()' method, you could
// also use the 'getFrameFromString()' or the
// 'getFrameFromTimecode()' methods:

$media = FFMpeg::open('steve_howe.mp4');
$frame = $media->getFrameFromString('00:00:13.37');

// or

$timecode = new FMpeg\Coordinate\TimeCode(...);
$frame = $media->getFrameFromTimecode($timecode);
```

With the `Media` class you can determinate the duration of a file:

```
$media = FFMpeg::open('wwdc_2006.mp4');

$durationInSeconds = $media->getDurationInSeconds(); // returns an int
$durationInMiliseconds = $media->getDurationInMiliseconds(); // returns a float
```

When opening or saving files from or to a remote disk, temporary files will be created on your server. After you're done exporting or processing these files, you could clean them up by calling the `cleanupTemporaryFiles()` method:

```
FFMpeg::cleanupTemporaryFiles();
```

HLS
---

[](#hls)

You can create a M3U8 playlist to do [HLS](https://en.wikipedia.org/wiki/HTTP_Live_Streaming). Exporting is currently only supported on local disks.

```
$lowBitrate = (new X264)->setKiloBitrate(250);
$midBitrate = (new X264)->setKiloBitrate(500);
$highBitrate = (new X264)->setKiloBitrate(1000);

FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->exportForHLS()
    ->setSegmentLength(10) // optional
    ->addFormat($lowBitrate)
    ->addFormat($midBitrate)
    ->addFormat($highBitrate)
    ->save('adaptive_steve.m3u8');
```

As of version 1.2.0 the `addFormat` method of the HLS exporter takes an optional second parameter which can be a callback method. This allows you to add different filters per format:

```
$lowBitrate = (new X264)->setKiloBitrate(250);
$highBitrate = (new X264)->setKiloBitrate(1000);

FFMpeg::open('steve_howe.mp4')
    ->exportForHLS()
    ->addFormat($lowBitrate, function($media) {
        $media->addFilter(function ($filters) {
            $filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
        });
    })
    ->addFormat($highBitrate, function($media) {
        $media->addFilter(function ($filters) {
            $filters->resize(new \FFMpeg\Coordinate\Dimension(1280, 960));
        });
    })
    ->save('adaptive_steve.m3u8');
```

As of version 1.3.0 you can monitor the transcoding progress of a HLS export. Use the `onProgress` method to provide a callback which gives you the completed percentage.

```
$exporter = FFMpeg::open('steve_howe.mp4')
    ->exportForHLS()
    ->onProgress(function ($percentage) {
        echo "$percentage % transcoded";
    });
```

As of version 2.1.0 you can disable the sorting of the added formats as most players choose the first format as the default one.

```
$exporter = FFMpeg::open('steve_howe.mp4')
    ->exportForHLS()
    ->dontSortFormats();
```

Advanced
--------

[](#advanced)

The Media object you get when you 'open' a file, actually holds the Media object that belongs to the [underlying driver](https://github.com/PHP-FFMpeg/PHP-FFMpeg). It handles dynamic method calls as you can see [here](https://github.com/pascalbaljetmedia/laravel-ffmpeg/blob/master/src/Media.php#L114-L117). This way all methods of the underlying driver are still available to you.

```
// This gives you an instance of Pbmedia\LaravelFFMpeg\Media
$media = FFMpeg::fromDisk('videos')->open('video.mp4');

// The 'getStreams' method will be called on the underlying Media object since
// it doesn't exists on this object.
$codec = $media->getStreams()->first()->get('codec_name');
```

If you want direct access to the underlying object, call the object as a function (invoke):

```
// This gives you an instance of Pbmedia\LaravelFFMpeg\Media
$media = FFMpeg::fromDisk('videos')->open('video.mp4');

// This gives you an instance of FFMpeg\Media\MediaTypeInterface
$baseMedia = $media();
```

Example app
-----------

[](#example-app)

Here's a blogpost that will help you get started with this package:

Wiki
----

[](#wiki)

- [Custom filters](https://github.com/pascalbaljetmedia/laravel-ffmpeg/wiki/Custom-filters)
- [FFmpeg failed to execute command](https://github.com/pascalbaljetmedia/laravel-ffmpeg/wiki/FFmpeg-failed-to-execute-command)
- [Get the dimensions of a Video file](https://github.com/pascalbaljetmedia/laravel-ffmpeg/wiki/Get-the-dimensions-of-a-Video-file)
- [Monitoring the transcoding progress](https://github.com/pascalbaljetmedia/laravel-ffmpeg/wiki/Monitoring-the-transcoding-progress)
- [Unable to load FFProbe](https://github.com/pascalbaljetmedia/laravel-ffmpeg/wiki/Unable-to-load-FFProbe)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker. Please do not email any questions, open an issue if you have a question.

Credits
-------

[](#credits)

- [Pascal Baljet](https://github.com/pascalbaljet)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance45

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fcf1080ff234e0c4a3c3c06187211ac43ae811c21d66a2d0a3d6b420536cac0?d=identicon)[lambq](/maintainers/lambq)

---

Top Contributors

[![xiaoxie4727](https://avatars.githubusercontent.com/u/17850662?v=4)](https://github.com/xiaoxie4727 "xiaoxie4727 (7 commits)")

---

Tags

laravel-ffmpeglambq

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lambq-laravel-ffmpeg/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M368](/packages/laravel-zero-framework)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[sammyjo20/lasso

Lasso - Asset wrangling for Laravel made simple.

355347.9k](/packages/sammyjo20-lasso)

PHPackages © 2026

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