2017 © Pedro Peláez
 

symfony-bundle ffmpeg-bundle

Symfony bundle to provide PHP-FFmpeg (https://github.com/PHP-FFmpeg/PHP-FFmpeg) as a Symfony service

image

sujayjaju/ffmpeg-bundle

Symfony bundle to provide PHP-FFmpeg (https://github.com/PHP-FFmpeg/PHP-FFmpeg) as a Symfony service

  • Thursday, June 11, 2015
  • by sujayjaju
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,056 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 0 Open issues
  • 9 Versions
  • 3 % Grown

The README.md

Symfony ffmpeg bundle

This bundle provides a simple wrapper for the PHP_FFmpeg library, exposing it as a Symfony service., (*1)

Based on pulse00/ffmpeg-bundle by pulse00, (*2)

Usage Example

Enable the extension in the AppKernel, (*3)

``` php .... new sujayjaju\FFmpegBundle\PhpFFmpegBundle(), ...., (*4)


Configure which ffmpeg binary to use in `config.yml`: ``` yaml php_ffmpeg: ffmpeg_binary: /usr/bin/ffmpeg ffprobe_binary: /usr/bin/ffprobe binary_timeout: 300 # Use 0 for infinite threads_count: 4

Using the service:, (*5)

``` php $ffmpeg = $this->get('php_ffmpeg.ffmpeg');, (*6)

// Open video
$video = $ffmpeg->open('/your/source/folder/input.avi');

// Resize to 640x480
$video
    ->filters()
    ->resize(new Dimension(640, 480), ResizeFilter::RESIZEMODE_INSET)
    ->synchronize();

// Create a thumbnail
$video
    ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
    ->save('/PATH/frame.jpg');

// Start transcoding and save video
$video->save(new FMpeg\Format\Video\X264(), '/PATH/video.mp4');



### Sample Integration With [1up-lab/OneupUploaderBundle](https://github.com/1up-lab/OneupUploaderBundle) * Step 1: Create Your Upload Listener Class ``` php namespace Application\YourBundle\EventListener; use FFMpeg\Exception\InvalidArgumentException; use FFMpeg\Exception\RuntimeException; use Oneup\UploaderBundle\Event\PostUploadEvent; class YourUploadListener { protected $doctrine; protected $ffmpeg; public function __construct($doctrine, $ffmpeg) { $this->doctrine = $doctrine; $this->ffmpeg = $ffmpeg; } public function onUpload(PostUploadEvent $event) { $file_path = $event->getFile()->getPathname(); $response = $event->getResponse(); $video = null; try{ $ffmpeg = $this->ffmpeg->open($file_path); }catch(InvalidArgumentException $e){ $response->setSuccess(false); $response->setError("Could not load file"); $response['preventRetry'] = true; unlink($file_path); return; }catch(RuntimeException $e){ $response->setSuccess(false); $response->setError("Invalid File"); $response['preventRetry'] = true; unlink($file_path); return; } // Sample code to check if video was uploaded $streams = $ffmpeg->getStreams(); foreach($streams as $stream){ if($stream->get('codec_type') == 'video'){ $video = $stream; } } if(is_null($video)){ $response->setSuccess(false); $response->setError("Invalid Video"); $response['preventRetry'] = true; unlink($file_path); return; } // Do what you want with the video // $video } }
  • Step 2: Define your service

``` yaml, (*7)

application.your_upload_listener:
    class: Application\YourBundle\EventListener\YourUploadListener
    arguments: [@doctrine, @php_ffmpeg.ffmpeg]
    tags:
      -  { name: kernel.event_listener, event: oneup_uploader.post_upload, method: onUpload }

```, (*8)

The Versions

11/06 2015

dev-master

9999999-dev

Symfony bundle to provide PHP-FFmpeg (https://github.com/PHP-FFmpeg/PHP-FFmpeg) as a Symfony service

  Sources   Download

MIT

The Requires

 

by Robert Gruendler
by Sujay Jaju

multimedia ffmpeg php-ffmpeg

27/08 2014

0.5.2

0.5.2.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

27/08 2014

0.5.1

0.5.1.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

27/08 2014

0.5.0

0.5.0.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

12/04 2014

0.2.3

0.2.3.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

30/09 2013

0.2.2

0.2.2.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

04/02 2013

0.2.1

0.2.1.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

04/02 2013

0.2.0

0.2.0.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg

31/10 2012

0.1.0

0.1.0.0

Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)

  Sources   Download

MIT

The Requires

 

by Robert Gruendler

multimedia ffmpeg