buonaparte / bnp-ffmpeg-module
This module provides a simple wrapper for the PHP_FFmpeg library, exposing the library as a Zend Framework service
dev-master
2014-06-12 12:32 UTC
Requires
- php: >=5.3.3
- php-ffmpeg/php-ffmpeg: 0.4.*@dev
- zendframework/zend-loader: ~2.1
- zendframework/zend-modulemanager: ~2.1
- zendframework/zend-mvc: ~2.1
- zendframework/zend-servicemanager: ~2.1
- zendframework/zend-stdlib: ~2.1
Requires (Dev)
- phpunit/phpunit: >=3.7,<4
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: 1.4.*
This package is not auto-updated.
Last update: 2024-12-17 02:59:21 UTC
README
This module provides a simple wrapper for the PHP_FFmpeg library, exposing the library as a ZendFramework service.
Installation
Setup
-
Add this project to your composer.json:
"require": { "buonaparte/bnp-ffmpeg-module": "dev-master" }
-
Now tell composer to download BnpFFMpegModule by running the command:
$ php composer.phar update
Post installation
Enabling it in your application.config.php
file.
<?php return array( 'modules' => array( // ... 'BnpFFMpegModule', ), // ... );
Configuration
Configure the module, by copying and adjusting config/module.config.php.dist
to your config include path:
$ffmpegConfig = array( 'configuration' => array( 'ffmpeg.threads' => 4, 'ffmpeg.timeout' => 300, 'ffmpeg.binaries' => '/opt/local/ffmpeg/bin/ffmpeg', ), /** * Custom logger service, must resolve to a Psr\Logger\LoggerInterface instance pulled from the ServiceManager */ 'logger' => 'ffmpeg_logger', /** * Custom FFProbe service, pulled from the ServiceManager */ 'ffprobe' => 'ffprobe_service' ); return array( /** * Root Module configuration */ 'bnp-ffmpeg-module' => array( /** * For single ffmpeg service instance you can just uncomment the bellow line */ // 'ffmpeg' => $ffmpegConfig, /** * For multiple ffmpeg services with different configuration you will specify them in an array, * from to the service name to service configuration */ // 'ffmpeg' => array( // 'FFMpeg1' => array_merge_recursive($ffmpegConfig, array()), // 'FFMpeg2' => array_merge_recursive($ffmpegConfig, array()), // ), /** * FFProbe configuration */ 'ffprobe' => array( 'configuration' => array( 'ffprobe.timeout' => 30, 'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe', ), /** * Custom logger service must resolve to a Psr\Logger\LoggerInterface instance pulled from the ServiceManager */ 'logger' => 'ffprobe_logger', /** * Custom cache service must resolve to a Doctrine\Common\Cache\Cache instance pulled from the ServiceManager */ 'cache' => 'ffprobe_cache' ) ), /** * Service Manager config */ 'service_manager' => array( // 'factories' => array( // /** // * FFProbe service factory // */ // 'FFProbe' => 'BnpFFMpegModule\Factory\FFProbeServiceFactory', // /** // * For single ffmpeg service instance you can just register the factory for the service name // */ // 'FFMpeg' => 'BnpFFMpegModule\Factory\FFMpegServiceFactory' // ), // 'abstract_factories' => array( // /** // * For multiple ffmpeg service instances you must register the FFMpeg abstract factory // */ // 'BnpFFMpegModule\Factory\FFMpegAbstractServiceFactory' // ) ) );
Usage
$ffmpeg = $serviceLocator->get('FFMpeg'); // Open video $video = $ffmpeg->open('/your/source/folder/input.avi'); // Resize to 720x480 $video ->filters() ->resize(new Dimension(720, 480), ResizeFilter::RESIZEMODE_INSET) ->synchronize(); // Start transcoding and save video $video->save(new X264(), '/your/target/folder/video.mp4');