Author: Peter Hillerström [Github]
Calls ffmpeg
with the specified configuration upon video
upload.
Uses Symfony
Process
component to call command line utilities ffmpeg
and ffprobe
with the options configured in Filelib configuration upon a video upload.
The plugin uses FFmpegHelper class, which maps the Filelib
configuration options
to POSIX style command line arguments for ffmpeg
and ffprobe
.
FFmpeg version 0.9 or newer. Older
ones are missing the JSON output from ffprobe
.
You need to install FFmpeg with LGPL license, for it to be compatible with the Filelib's BSD license.
On Mac OS X you do this easily with MacPorts:
sudo port install ffmpeg-devel@-gpl2-nonfree
Example:
xi_filelib:
...
profiles:
video:
identifier: video
description: 'Video'
accessToOriginal: false
linker:
type: Xi\Filelib\Linker\SequentialLinker # Can use other types of linkers too
options:
filesPerDirectory: 500
directoryLevels: 3
plugins:
ffmpeg:
identifier: ffmpeg
type: Xi\Filelib\Plugin\Video\FFmpeg\FFmpegPlugin
profiles: [video]
command: 'ffmpeg' # Optional, can be an absolute path
options:
y: true # Overwrite existing files
loglevel: warning
# You may need to set the following values for larger videos:
# probesize: 100 # = 100 Mb, defaults to 5 Mb
# analyzeduration: 10000000 # = 10 s, defaults to 5 s
inputs:
original:
filename: true # Will be replaced by the uploaded file. Can be repeated on input filenames.
options:
ss: '00:00:01.000' # Seek to one second
r: 1 # Rate is 1 frames per second
vframes: 1 # Process one video frame
outputs:
1080p_still:
filename: 1080p_still.jpg
options:
s: '1920x1080'
vframes: 1
720p_still:
filename: 720p_still.jpg
options:
s: '1280x720'
vframes: 1
480p_still:
filename: 480p_still.jpg
options:
s: '854x480'
vframes: 1
135_thumb:
filename: 135_thumb.jpg
options:
s: '240x135'
vframes: 1
To create the output 1080p_still
for an uploaded video called Manatees.mp4
,
the above example will call ffmpeg
with the following options:
ffmpeg -y -loglevel 'warning' -ss '00:00:01.000' -r 1 -vframes 1 -i 'Manatees.mp4' \
-s '1920x1080' -vframes 1 'filelib/public/path/id/1080p_still.jpg'
Only saves one output file per configured output. In other words, the numbered output files are not supported for now.
- RabbitMQ or some other message queue implementing the AMQP protocol.
- Zencoder account and the zencoder-php library.
- Amazon S3 account and the ZendService\Amazon component, which has been broken since Zend 2.0.0-beta versions, but the version 2.0.3 will be fixed. Meanwhile, see my branch for the fixes. On Filelib version 0.7, the older version 1.1.2 of the Zend Service Amazon S3 used to work.
Install the requirements with Composer:
php composer.phar install --dev
Or copy the required Php-amqplib, Zencoder-php and Zend components into your composer:
{
// other stuff removed
"repositories": {
"zendframework": {
"type": "composer",
"url": "http://packages.zendframework.com/"
},
"zencoder-php": {
"type": "package",
"package": {
"name": "zencoder/zencoder-php",
"version": "2.0.2",
"source": {
"url": "git://github.com/zencoder/zencoder-php.git",
"type": "git",
"reference": "v2.0.2"
}
}
}
},
"require": {
"videlalvaro/php-amqplib": ">=dev-master",
"zencoder/zencoder-php": "2.0.2",
"zendframework/zendservice-amazon": "2.0.*",
"zendframework/zend-i18n": "2.0.*",
"zendframework/zend-filter": "2.0.*",
"zendframework/zend-servicemanager": "2.0.*"
}
}