Symfony Bundle to handle image and video
RenusMediaBundle is a collection of code within a Symfony 2 Bundle to handle image and video, you can create an image or animated gif from a video source or resize, obfuscate and crop an image in Symfony 2., (*1)
To use RenusMediaBundle in your project add it via composer, (*2)
To use RenusMediaBundle you must install and know the path of 'ffmpeg' binary (on Debian):, (*3)
apt-get install ffmpeg php5-ffmpeg php5-imagick
if you use a non standard Debian installation, you must specify the path to ffmpeg in your parameters file :, (*4)
parameters: binary: '/usr/bin/ffmpeg'
{ "require": { "renus/media": "0.*", } }
composer.phar require renus/media dev-master
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new \Renus\MediaBundle\RenusMediaBundle(), ); // ... }
In Symfony 2 controller, you can use it like a service, (*5)
extract the image at 55 seconds, (*6)
<?php $this->container->get('renus.video')->getPicsFromVideo( '/path/to/video/vid1.m4v', 55, '/path/to/generate/image/vid1.jpg' );
get an image every 10 seconds to build the animated gif, (*7)
<?php $this->container->get('renus.video')->generateAnimatedGifFromVideo( '/path/to/video/vid1.m4v', 10, '/path/to/generate/image/vid1.gif' );
Choose the destination path and the max size (300px here), (*8)
<?php $this->container->get('renus.image') ->init('/path/to/image.jpg') ->createThumb('/path/to/resize-thumb.jpg', 300);
Choose the destination path , define the start X point and the start Y point, the width and the height of the selection., (*9)
<?php $this->container->get('renus.image') ->init('/path/to/image.jpg') ->crop('/path/to/crop-thumb.jpg', 100, 25, 300, 250);