History of LibertyMime FLV Plugin
Version 11
LibertyMime FLV Plugin
a treasury plugin that converts videos of various formats to flashvideo
{r2}
The flv plugin is a video handler for treasury. it will convert videos of various formats including avi, mpg, mov and more to flashvideo and allowing you to conveniently view the converted video from within your browser. A site that uses a similar process is youtube.
The conversion process can be lengthy and therefore it is possible to run the conversion using a cron job. The cron php file is already present and all that needs to be done is add the appropriate cron job to your cron file, set the cron option in treasury and everything is set. This plugin also requires a recent version of ffmpeg. In fact, you need to compile the svn version of ffmpeg as other versions don't support conversion to .flv files (luckily, gentoo users only need to emerge --sync and compile the regular version of ffmpeg...).
The plugin also supports the use of ffmpeg-php. This extension is not required but will enable bitweaver to extract video information such as video duration and other useless but handy information to improve processing and therefor final result.
Example of serverside converted videos
If you want to make use of the flv plugin, you need to install the svn version of ffmpeg. only the latest version of ffmpeg supports the flv format. Your distribution might already include a version that supports flv.
some distros as examples:
as a cron job. Set up a cron job similar to the following. This will check for
open conversion jobs every minute:
all it allows us to do is check the aspect ratio and video length. This allows us to extract more appropriate video images and make more accurate conversions.
If you compile it as an extension, it should be recognised by this script. If you decide to compile it into your php, please modify the script below where it says:
To make full use of treasury related attachments in wiki pages in general, make sure you activate the treasury storage plugin and the flashvideo data plugin in the liberty plugins admin page as well.
Feel free to run your own tests and post your results here or append them as a comment
The flv plugin is a video handler for treasury. it will convert videos of various formats including avi, mpg, mov and more to flashvideo and allowing you to conveniently view the converted video from within your browser. A site that uses a similar process is youtube.
Installtion
The flv plugin for treasury is quite sophisticated. You need to install software on the server (you might even have to compile some binaries yourself), optionally install some php extension and install or activate a few files in bitweaver. if you are not prepared to do this, there isn't much point in reading on.The conversion process can be lengthy and therefore it is possible to run the conversion using a cron job. The cron php file is already present and all that needs to be done is add the appropriate cron job to your cron file, set the cron option in treasury and everything is set. This plugin also requires a recent version of ffmpeg. In fact, you need to compile the svn version of ffmpeg as other versions don't support conversion to .flv files (luckily, gentoo users only need to emerge --sync and compile the regular version of ffmpeg...).
The plugin also supports the use of ffmpeg-php. This extension is not required but will enable bitweaver to extract video information such as video duration and other useless but handy information to improve processing and therefor final result.
Example of serverside converted videos
ffmpeg (required)
You can find some more help in treasury/plugins/cron.flv.phpIf you want to make use of the flv plugin, you need to install the svn version of ffmpeg. only the latest version of ffmpeg supports the flv format. Your distribution might already include a version that supports flv.
Install
You will need the svn version of ffmpeg and you will have to compile this yourself:some distros as examples:
Gentoo
ffmpeg and available use flags- X
- a52
- aac
- altivec
- amr
- debug
- doc
- dts
- encode
- ieee1394
- imlib
- mmx
- network
- ogg
- oss
- sdl
- test
- theora
- threads
- truetype
- v4l
- vorbis
- x264
- xvid
- zlib
Ubuntu
Fedora Core 6
at the time of writing this, the version in livna was faulty - i used the one in freshrpms:
# rpm -ihv http://ayo.freshrpms.net/fedora/linux/6/i386/RPMS.freshrpms/freshrpms-release-1.1-1.fc.noarch.rpm
# yum install ffmpeg
generic instructions getting ffmpeg from svn
$ svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
$ cd ffmpeg
$ ./configure --help | grep enable
$ ./configure --enable-libmp3lame --enable-gpl
$ make
# make install
Depending on the system, you might be able to support more formats.
./configure --enable-mp3lame --enable-gpl --enable-a52 --enable-libogg --enable-vorbis --enable-xvid
./configure --enable-mp3lame --enable-gpl --enable-a52 --enable-libogg --enable-vorbis --enable-xvid
Setting up cron jobs
Processing video files can take a while and this process is therefore designedas a cron job. Set up a cron job similar to the following. This will check for
open conversion jobs every minute:
* * * * * apache /path/to/php -q /path/to/cron.flv.php [number of videos to process] >> /path/to/log/file.log
- make sure apache is your apache user - you can check the 'User' setting in your apache.conf file (usually located at /etc/apache2/httpd.conf)
- number of videos to process is optional, default is 3
ffmpeg-php (optional)
ffmpeg-php is a php extension that makes it possible to easily access video information from within php. Please view the official site on how to add ffmpeg-php to your php setup: http://ffmpeg-php.sourceforge.netall it allows us to do is check the aspect ratio and video length. This allows us to extract more appropriate video images and make more accurate conversions.
If you compile it as an extension, it should be recognised by this script. If you decide to compile it into your php, please modify the script below where it says:
<?php
if( extension_loaded( 'ffmpeg' )) {
}
?>
Plugins
Once the software is in place you need to make sure the flv plugin is active in the treasury plugin admin screen. As soon as this is active some plugin specific options will appear. Please see below for details.To make full use of treasury related attachments in wiki pages in general, make sure you activate the treasury storage plugin and the flashvideo data plugin in the liberty plugins admin page as well.
Plugin settings
In the treasury plugin admin screen there are a few flv-specific options you can set. Please make sure that the suggested path to ffmpeg is correct. without this no videos will be converted. The video and audio settings are basically: the higher the better the quality but also the larger the download.Video conversion results
Here are some basic tests i made using a 60 second high quality divx film. I only include 2 bitrates and i've removed a few sizes to reduce table size.Video bitrate (bits/s) | Audio bitrate (bits/s) | Audio samplerate (Hz) | Video size (pixel x pixel) | File size (bytes) | Encoding time (s) |
---|---|---|---|---|---|
200 | 32 | 22050 | 320x180 | 1724 (1.7M) | 10 |
200 | 32 | 22050 | 480x270 | 1820 (1.8M) | 15 |
200 | 32 | 22050 | 640x360 | 2128 (2.1M) | 22 |
200 | 32 | 44100 | 320x180 | 2148 (2.1M) | 13 |
200 | 32 | 44100 | 480x270 | 2244 (2.2M) | 17 |
200 | 32 | 44100 | 640x360 | 2552 (2.5M) | 22 |
200 | 64 | 22050 | 320x180 | 1724 (1.7M) | 10 |
200 | 64 | 22050 | 480x270 | 1820 (1.8M) | 16 |
200 | 64 | 22050 | 640x360 | 2128 (2.1M) | 20 |
200 | 64 | 44100 | 320x180 | 2148 (2.1M) | 12 |
200 | 64 | 44100 | 480x270 | 2244 (2.2M) | 17 |
200 | 64 | 44100 | 640x360 | 2552 (2.5M) | 23 |
400 | 32 | 22050 | 320x180 | 2780 (2.8M) | 11 |
400 | 32 | 22050 | 480x270 | 2844 (2.8M) | 16 |
400 | 32 | 22050 | 640x360 | 2864 (2.8M) | 21 |
400 | 32 | 44100 | 320x180 | 3204 (3.2M) | 17 |
400 | 32 | 44100 | 480x270 | 3268 (3.2M) | 17 |
400 | 32 | 44100 | 640x360 | 3288 (3.3M) | 23 |
400 | 64 | 22050 | 320x180 | 2780 (2.8M) | 11 |
400 | 64 | 22050 | 480x270 | 2844 (2.8M) | 15 |
400 | 64 | 22050 | 640x360 | 2864 (2.8M) | 21 |
400 | 64 | 44100 | 320x180 | 3204 (3.2M) | 13 |
400 | 64 | 44100 | 480x270 | 3268 (3.2M) | 17 |
400 | 64 | 44100 | 640x360 | 3288 (3.3M) | 26 |
Video conversion test script
#!/bin/bash
# path to video file to convert
videofile="video.avi"
# aspect ratio of the video
aspect="16:9"
# various sizes bitweaver can create - width is set by bitweaver, calculate video hight as determined by the aspect ratio of the video
size="240x136 320x180 480x270 640x360"
# settings
video_bitrate="160000 240000 320000 400000"
audio_samplerate="11025 22050 44100"
audio_bitrate="16 32 64 96"
echo '{| style="text-align:right"
|+ Full results table
! Video bitrate (bits/s)
! Audio samplerate (Hz)
! Audio bitrate (bits/s)
! Video size (pixel x pixel)
! File size (bytes)
! Encoding time (s)' > results.wiki
for b in $video_bitrate; do
for ar in $audio_samplerate; do
for ab in $audio_bitrate; do
for z in $size; do
begin=`date +%s`
name="flv-$b-$ar-$ab-$z"
ffmpeg -i $videofile -acodec mp3 -b $b -ar $ar -ab $ab -f flv -s $z -aspect $aspect -y $name
now=`date +%s`
duration=$(($now - $begin))
bytes=`ls -s $name | sed 's/ .*$//'`
hbytes=`ls -sh $name | sed 's/ .*$//'`
echo "|-"
echo "|$b || $ar || $ab || $z || $bytes ($hbytes) || $duration" >> results.wiki
mv $name "$name-$duration.flv"
done
done
done
done
echo "|}" >> results.wiki
Feel free to run your own tests and post your results here or append them as a comment