PHPackages                             soluciones-gbh/php-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. [Image &amp; Media](/categories/media)
4. /
5. soluciones-gbh/php-ffmpeg

AbandonedArchivedLibrary[Image &amp; Media](/categories/media)

soluciones-gbh/php-ffmpeg
=========================

FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg

0.6.0(11y ago)0142MITPHPPHP &gt;=5.3.3

Since Oct 30Pushed 9y agoCompare

[ Source](https://github.com/soluciones-gbh/PHP-FFMpeg)[ Packagist](https://packagist.org/packages/soluciones-gbh/php-ffmpeg)[ RSS](/packages/soluciones-gbh-php-ffmpeg/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (7)Versions (35)Used By (0)

\#PHP FFmpeg

[![Build Status](https://camo.githubusercontent.com/a4fb5519d9a9d5bc531bd84a7e456298aa5f977b367d052ac55c4dd7eb1a341d/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f5048502d46464d7065672f5048502d46464d7065672e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/PHP-FFMpeg/PHP-FFMpeg)

[![SensioLabsInsight](https://camo.githubusercontent.com/befb735cd4f818264540aec516e0b867328d4e665a822d39c1a45d32fc0b8860/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36303766333131312d653264372d343465382d386263632d3534646436343532313938332f6269672e706e67)](https://insight.sensiolabs.com/projects/607f3111-e2d7-44e8-8bcc-54dd64521983)

An Object Oriented library to convert video/audio files with FFmpeg / AVConv.

Check another amazing repo : [PHP FFMpeg extras](https://github.com/alchemy-fr/PHP-FFMpeg-Extras), you will find lots of Audio/Video formats there.

Your attention please
---------------------

[](#your-attention-please)

### How this library works :

[](#how-this-library-works-)

This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it. Be sure that these binaries can be located with system PATH to get the benefit of the binary detection, otherwise you should have to explicitely give the binaries path on load.

For Windows users : Please find the binaries at .

### Known issues :

[](#known-issues-)

- Using rotate and resize will produce a corrupted output when using [libav](http://libav.org/) 0.8. The bug is fixed in version 9. This bug does not appear in latest ffmpeg version.

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

[](#installation)

The recommended way to install PHP-FFMpeg is through [Composer](https://getcomposer.org).

```
{
    "require": {
        "php-ffmpeg/php-ffmpeg": "~0.5"
    }
}
```

Basic Usage
-----------

[](#basic-usage)

```
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
$video
    ->filters()
    ->resize(new FFMpeg\Coordinate\Dimension(320, 240))
    ->synchronize();
$video
    ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
    ->save('frame.jpg');
$video
    ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4')
    ->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
    ->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');
```

Documentation
-------------

[](#documentation)

This documentation is an introduction to discover the API. It's recommended to browse the source code as it is self-documented.

### FFMpeg

[](#ffmpeg)

`FFMpeg\FFMpeg` is the main object to use to manipulate medias. To build it, use the static `FFMpeg\FFMpeg::create` :

```
$ffmpeg = FFMpeg\FFMpeg::create();
```

FFMpeg will autodetect ffmpeg and ffprobe binaries. If you want to give binary paths explicitely, you can pass an array as configuration. A `Psr\Logger\LoggerInterface`can also be passed to log binary executions.

```
$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => '/opt/local/ffmpeg/bin/ffmpeg',
    'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe',
    'timeout'          => 3600, // The timeout for the underlying process
    'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
), $logger);
```

### Manipulate media

[](#manipulate-media)

`FFMpeg\FFMpeg` creates media based on URIs. URIs could be either a pointer to a local filesystem resource, an HTTP resource or any resource supported by FFmpeg.

**Note** : To list all supported resource type of your FFmpeg build, use the `-protocols` command :

```
ffmpeg -protocols

```

To open a resource, use the `FFMpeg\FFMpeg::open` method.

```
$ffmpeg->open('video.mpeg');
```

Two types of media can be resolved : `FFMpeg\Media\Audio` and `FFMpeg\Media\Video`. A third type, `FFMpeg\Media\Frame`, is available through videos.

#### Video

[](#video)

`FFMpeg\Media\Video` can be transcoded, ie : change codec, isolate audio or video. Frames can be extracted.

##### Transcoding

[](#transcoding)

You can transcode videos using the `FFMpeg\Media\Video:save` method. You will pass a `FFMpeg\Format\FormatInterface` for that.

Please note that audio and video bitrate are set on the format.

```
$format = new Format\Video\X264();
$format->on('progress', function ($video, $format, $percentage) {
    echo "$percentage % transcoded";
});

$format
    -> setKiloBitrate(1000)
    -> setAudioChannels(2)
    -> setAudioKiloBitrate(256);

$video->save($format, 'video.avi');
```

Transcoding progress can be monitored in realtime, see Format documentation below for more informations.

##### Extracting image

[](#extracting-image)

You can extract a frame at any timecode using the `FFMpeg\Media\Video::frame`method.

This code return a `FFMpeg\Media\Frame` instance corresponding to the second 42. You can pass any `FFMpeg\Coordinate\TimeCode` as argument, see dedicated documentation below for more information.

```
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42));
$frame->save('image.jpg');
```

##### Filters

[](#filters)

You can apply filters on `FFMpeg\Media\Video` with the `FFMpeg\Media\Video::addFilter`method. Video accepts Audio and Video filters.

You can build your own filters and some are bundled in PHP-FFMpeg - they are accessible through the `FFMpeg\Media\Video::filters` method.

Filters are chainable

```
$video
    ->filters()
    ->resize($dimension, $mode, $useStandards)
    ->framerate($framerate, $gop)
    ->synchronize();
```

###### Rotate

[](#rotate)

Rotates a video to a given angle.

```
$video->filters()->rotate($angle);
```

The `$angle` parameter must be one of the following constants :

- `FFMpeg\Filters\Video\RotateFilter::ROTATE_90` : 90° clockwise
- `FFMpeg\Filters\Video\RotateFilter::ROTATE_180` : 180°
- `FFMpeg\Filters\Video\RotateFilter::ROTATE_270` : 90° counterclockwise

###### Resize

[](#resize)

Resizes a video to a given size.

```
$video->filters()->resize($dimension, $mode, $useStandards);
```

The resize filter takes three parameters :

- `$dimension`, an instance of `FFMpeg\Coordinate\Dimension`
- `$mode`, one of the constants `FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_*` constants
- `$useStandards`, a boolean to force the use of the nearest aspect ratio standard.

###### Watermark

[](#watermark)

Watermark a video with a given image.

```
$video
    ->filters()
    ->watermark($watermarkPath, array(
        'position' => 'relative',
        'bottom' => 50,
        'right' => 50,
    ));
```

The watermark filter takes two parameters:

`$watermarkPath`, the path to your watermark file. `$coordinates`, an array defining how you want your watermark positioned. You can use relative positioning as demonstrated above or absolute as such:

```
$video
    ->filters()
    ->watermark($watermarkPath, array(
        'position' => 'absolute',
        'x' => 1180,
        'y' => 620,
    ));
```

###### Framerate

[](#framerate)

Changes the frame rate of the video.

```
$video->filters()->framerate($framerate, $gop);
```

The framerate filter takes two parameters :

- `$framerate`, an instance of `FFMpeg\Coordinate\Framerate`
- `$gop`, a [GOP](https://wikipedia.org/wiki/Group_of_pictures) value (integer)

###### Synchronize

[](#synchronize)

Synchronizes audio and video.

Some containers may use a delay that results in desynchronized outputs. This filters solves this issue.

```
$video->filters()->synchronize();
```

###### Clip

[](#clip)

Cuts the video at a desired point.

```
$video->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15));
```

The clip filter takes two parameters:

- `$start`, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the start point of the clip
- `$duration`, optional, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the duration of the clip

#### Audio

[](#audio)

`FFMpeg\Media\Audio` can be transcoded, ie : change codec, isolate audio or video. Frames can be extracted.

##### Transcoding

[](#transcoding-1)

You can transcode audios using the `FFMpeg\Media\Audio:save` method. You will pass a `FFMpeg\Format\FormatInterface` for that.

Please note that audio kilobitrate is set on the audio format.

```
$ffmpeg = FFMpeg\FFMpeg::create();
$audio = $ffmpeg->open('track.mp3');

$format = new FFMpeg\Format\Audio\Flac();
$format->on('progress', function ($audio, $format, $percentage) {
    echo "$percentage % transcoded";
});

$format
    -> setAudioChannels(2)
    -> setAudioKiloBitrate(256);

$audio->save($format, 'track.flac');
```

Transcoding progress can be monitored in realtime, see Format documentation below for more informations.

##### Filters

[](#filters-1)

You can apply filters on `FFMpeg\Media\Audio` with the `FFMpeg\Media\Audio::addFilter`method. It only accepts audio filters.

You can build your own filters and some are bundled in PHP-FFMpeg - they are accessible through the `FFMpeg\Media\Audio::filters` method.

###### Resample

[](#resample)

Resamples an audio file.

```
$audio->filters()->resample($rate);
```

The resample filter takes two parameters :

- `$rate`, a valid audio sample rate value (integer)

#### Frame

[](#frame)

A frame is a image at a timecode of a video ; see documentation above about frame extraction.

You can save frames using the `FFMpeg\Media\Frame::save` method.

```
$frame->save('target.jpg');
```

This method has a second optional boolean parameter. Set it to true to get accurate images ; it takes more time to execute.

#### Formats

[](#formats)

A format implements `FFMpeg\Format\FormatInterface`. To save to a video file, use `FFMpeg\Format\VideoInterface`, and `FFMpeg\Format\AudioInterface` for audio files.

Format can also extends `FFMpeg\Format\ProgressableInterface` to get realtime informations about the transcoding.

Predefined formats already provide progress informations as events.

```
$format = new Format\Video\X264();
$format->on('progress', function ($video, $format, $percentage) {
    echo "$percentage % transcoded";
});

$video->save($format, 'video.avi');
```

The callback provided for the event can be any callable.

##### Create your own format

[](#create-your-own-format)

The easiest way to create a format is to extend the abstract `FFMpeg\Format\Video\DefaultVideo` and `FFMpeg\Format\Audio\DefaultAudio`. and implement the following methods.

```
class CustomWMVFormat extends FFMpeg\Format\Video\DefaultVideo
{
    public function __construct($audioCodec = 'wmav2', $videoCodec = 'wmv2')
    {
        $this
            ->setAudioCodec($audioCodec)
            ->setVideoCodec($videoCodec);
    }

    public function supportBFrames()
    {
        return false;
    }

    public function getAvailableAudioCodecs()
    {
        return array('wmav2');
    }

    public function getAvailableVideoCodecs()
    {
        return array('wmv2');
    }
}
```

#### Coordinates

[](#coordinates)

FFMpeg use many units for time and space coordinates.

- `FFMpeg\Coordinate\AspectRatio` represents an aspect ratio.
- `FFMpeg\Coordinate\Dimension` represent a dimension.
- `FFMpeg\Coordinate\FrameRate` represent a framerate.
- `FFMpeg\Coordinate\Point` represent a point.
- `FFMpeg\Coordinate\TimeCode` represent a timecode.

### FFProbe

[](#ffprobe)

`FFMpeg\FFProbe` is used internally by `FFMpeg\FFMpeg` to probe medias. You can also use it to extract media metadata.

```
$ffprobe = FFMpeg\FFProbe::create();
$ffprobe
    ->streams('/path/to/video/mp4') // extracts streams informations
    ->videos()                      // filters video streams
    ->first()                       // returns the first video stream
    ->get('codec_name');            // returns the codec_name property
```

```
$ffprobe = FFMpeg\FFProbe::create();
$ffprobe
    ->format('/path/to/video/mp4') // extracts file informations
    ->get('duration');             // returns the duration property
```

\##Using with Silex Microframework

Service provider is easy to set up :

```
$app = new Silex\Application();
$app->register(new FFMpeg\FFMpegServiceProvider());

$video = $app['ffmpeg']->open('video.mpeg');
```

Available options are as follow :

```
$app->register(new FFMpeg\FFMpegServiceProvider(), array(
    'ffmpeg.configuration' => array(
        'ffmpeg.threads'   => 4,
        'ffmpeg.timeout'   => 300,
        'ffmpeg.binaries'  => '/opt/local/ffmpeg/bin/ffmpeg',
        'ffprobe.timeout'  => 30,
        'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe',
    ),
    'ffmpeg.logger' => $logger,
));
```

API Browser
-----------

[](#api-browser)

Browse the [API](http://readthedocs.org/docs/ffmpeg-php/en/latest/_static/API/)

License
-------

[](#license)

This project is licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 84.7% 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 ~47 days

Recently: every ~23 days

Total

31

Last Release

3577d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.3.3

0.5.3PHP ^5.3.9 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c430ad6ef9959bb139b60acb41c1f3e8571934c801c9647be5f243bed41b99a6?d=identicon)[matrunchyk](/maintainers/matrunchyk)

---

Top Contributors

[![romainneutron](https://avatars.githubusercontent.com/u/137574?v=4)](https://github.com/romainneutron "romainneutron (310 commits)")[![QuingKhaos](https://avatars.githubusercontent.com/u/993350?v=4)](https://github.com/QuingKhaos "QuingKhaos (14 commits)")[![nlegoff](https://avatars.githubusercontent.com/u/511494?v=4)](https://github.com/nlegoff "nlegoff (7 commits)")[![sujayjaju](https://avatars.githubusercontent.com/u/1681240?v=4)](https://github.com/sujayjaju "sujayjaju (4 commits)")[![luisalvarez](https://avatars.githubusercontent.com/u/1791272?v=4)](https://github.com/luisalvarez "luisalvarez (4 commits)")[![SimonSimCity](https://avatars.githubusercontent.com/u/392589?v=4)](https://github.com/SimonSimCity "SimonSimCity (4 commits)")[![cangelis](https://avatars.githubusercontent.com/u/1162691?v=4)](https://github.com/cangelis "cangelis (4 commits)")[![pulse00](https://avatars.githubusercontent.com/u/185278?v=4)](https://github.com/pulse00 "pulse00 (4 commits)")[![guimeira](https://avatars.githubusercontent.com/u/734144?v=4)](https://github.com/guimeira "guimeira (3 commits)")[![Hakunahaphantata](https://avatars.githubusercontent.com/u/20164607?v=4)](https://github.com/Hakunahaphantata "Hakunahaphantata (2 commits)")[![ryo-utsunomiya](https://avatars.githubusercontent.com/u/1718007?v=4)](https://github.com/ryo-utsunomiya "ryo-utsunomiya (2 commits)")[![tgabi333](https://avatars.githubusercontent.com/u/187022?v=4)](https://github.com/tgabi333 "tgabi333 (1 commits)")[![dv336699](https://avatars.githubusercontent.com/u/930792?v=4)](https://github.com/dv336699 "dv336699 (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![jperezg](https://avatars.githubusercontent.com/u/1847063?v=4)](https://github.com/jperezg "jperezg (1 commits)")[![mhor](https://avatars.githubusercontent.com/u/4103719?v=4)](https://github.com/mhor "mhor (1 commits)")[![MrHash](https://avatars.githubusercontent.com/u/390925?v=4)](https://github.com/MrHash "MrHash (1 commits)")[![seblavoie](https://avatars.githubusercontent.com/u/950207?v=4)](https://github.com/seblavoie "seblavoie (1 commits)")[![ak76](https://avatars.githubusercontent.com/u/736596?v=4)](https://github.com/ak76 "ak76 (1 commits)")

---

Tags

audiovideo processingvideoaudio processingavconvffmpegavprobeffprobe

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/soluciones-gbh-php-ffmpeg/health.svg)

```
[![Health](https://phpackages.com/badges/soluciones-gbh-php-ffmpeg/health.svg)](https://phpackages.com/packages/soluciones-gbh-php-ffmpeg)
```

###  Alternatives

[php-ffmpeg/php-ffmpeg

FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg

5.0k23.2M183](/packages/php-ffmpeg-php-ffmpeg)

PHPackages © 2026

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