PHPackages                             boz14676/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. boz14676/laravel-ffmpeg

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

boz14676/laravel-ffmpeg
=======================

FFMpeg for Laravel

4.0.4(7y ago)024MITPHPPHP ^7.1.3

Since Aug 10Pushed 7y agoCompare

[ Source](https://github.com/boz14676/laravel-ffmpeg)[ Packagist](https://packagist.org/packages/boz14676/laravel-ffmpeg)[ Docs](https://github.com/pbmedia/laravel-ffmpeg)[ RSS](/packages/boz14676-laravel-ffmpeg/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (9)Versions (33)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 5.8. The storage of the files is handled by [Laravel's Filesystem](http://laravel.com/docs/5.8/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/5.8/filesystem), [configuration system](https://laravel.com/docs/5.8/configuration) and [logging handling](https://laravel.com/docs/5.8/errors).
- Compatible with Laravel 5.8.
- Support for [Package Discovery](https://laravel.com/docs/5.8/packages#package-discovery).
- PHP 7.1, 7.2 and 7.3 only.

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

[](#installation)

Only the master branch and version 4.0 of this package are compatible with Laravel 5.8. If you're still using an older version of Laravel, please use the chart below to find out which version you should use. Mind that older versions are no longer supported.

Laravel VersionPackage Version5.84.05.73.05.62.15.1-5.51.3You can install the package via composer:

```
composer require pbmedia/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' => [
    ...
    Pbmedia\LaravelFFMpeg\FFMpegServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'FFMpeg' => Pbmedia\LaravelFFMpeg\FFMpegFacade::class
    ...
];
```

Publish the config file using the artisan CLI tool:

```
php artisan vendor:publish --provider="Pbmedia\LaravelFFMpeg\FFMpegServiceProvider"
```

Usage
-----

[](#usage)

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

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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~35 days

Recently: every ~14 days

Total

29

Last Release

2575d ago

Major Versions

1.3.0 → 2.0.02018-02-19

2.1.1 → 3.0.02018-09-06

3.0.2 → 4.0.02019-02-27

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.0PHP ^7.1

4.0.0PHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/9074f7f86a33ba357d020c1c2338f7284d4913efcd8aaea2bddb45e8f1ec039c?d=identicon)[boz14676](/maintainers/boz14676)

---

Top Contributors

[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (117 commits)")[![DevDynamo2024](https://avatars.githubusercontent.com/u/157688292?v=4)](https://github.com/DevDynamo2024 "DevDynamo2024 (4 commits)")[![joecampo](https://avatars.githubusercontent.com/u/3619398?v=4)](https://github.com/joecampo "joecampo (3 commits)")[![Dylan-DPC](https://avatars.githubusercontent.com/u/99973273?v=4)](https://github.com/Dylan-DPC "Dylan-DPC (2 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (2 commits)")[![chivincent](https://avatars.githubusercontent.com/u/7449005?v=4)](https://github.com/chivincent "chivincent (1 commits)")[![song374561](https://avatars.githubusercontent.com/u/5179499?v=4)](https://github.com/song374561 "song374561 (1 commits)")

---

Tags

laravel-ffmpegpbmedia

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[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.3M74](/packages/unisharp-laravel-filemanager)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)

PHPackages © 2026

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