Version 6

LibertyMime FLV Plugin

a treasury plugin that converts videos of various formats to flashvideo

Created by: xing, Last modification: 09 Jun 2007 (09:41 UTC) by xing
{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.

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 Help on External Sites

Here are some links to other sites that provide instructions on how to set up ffmpeg on various OSs:

taken from treasury/cron.flv.php


<?php
/* ================================= FFMPEG =================================
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.


--- INSTALL [required]
You will need the svn version of ffmpeg and you will have to compile this
yourself:

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --help | grep enable
./configure --enable-mp3lame --enable-gpl
make
make install
-- NOTE
Depending on the system, you might be able to support more formats. These are
the configure flags i used:
./configure --enable-mp3lame --enable-gpl --enable-a52 --enable-libogg \
--enable-vorbis --enable-xvid


--- CRON [optional]
Processing video files can take a while and this process is therefore designed to be
run as 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
-- NOTE
- 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 =================================
--- INSTALL [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.net

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:
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 600 second high quality divx film.
Video rate Audio rate Video size File size Encoding time Recommended
11025 16 240x136 16862250 (17M) 76
11025 16 320x180 16882052 (17M) 95
11025 16 480x270 17036850 (17M) 134
11025 16 640x360 23841898 (23M) 189
11025 32 240x136 18067121 (18M) 77
11025 32 320x180 18086923 (18M) 99
11025 32 480x270 18241721 (18M) 139
11025 32 640x360 25046769 (24M) 195
11025 64 240x136 20476865 (20M) 73
11025 64 320x180 20496667 (20M) 90
11025 64 480x270 20651465 (20M) 130
11025 64 640x360 27456513 (27M) 191
22050 16 240x136 17046610 (17M) 81
22050 16 320x180 17066412 (17M) 99
22050 16 480x270 17221210 (17M) 139
22050 16 640x360 24026258 (23M) 214
22050 32 240x136 18251377 (18M) 91
22050 32 320x180 18271179 (18M) 106 *****
22050 32 480x270 18425977 (18M) 151 ****
22050 32 640x360 25231025 (25M) 202
22050 64 240x136 20660911 (20M) 86
22050 64 320x180 20680713 (20M) 101
22050 64 480x270 20835511 (20M) 142
22050 64 640x360 27640559 (27M) 200
44100 16 240x136 0 ( 0) 0
44100 16 320x180 0 ( 0) 0
44100 16 480x270 0 ( 0) 0
44100 16 640x360 0 ( 0) 0
44100 32 240x136 18251256 (18M) 100
44100 32 320x180 18271058 (18M) 114
44100 32 480x270 18425856 (18M) 156
44100 32 640x360 25230904 (25M) 213
44100 64 240x136 20660686 (20M) 110
44100 64 320x180 20680488 (20M) 127 ****
44100 64 480x270 20835286 (20M) 174 ***
44100 64 640x360 27640334 (27M) 234


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"

# video quality settings availabe in bitweaver
video="11025 22050 44100"
audio="16 32 64"

echo "! Video conversion results" > results.wiki
echo "||~ Video rate | Audio rate | Video size | File size | Encoding time" >> results.wiki

for v in $video; do
    for a in $audio; do
        for z in $size; do
            begin=`date +%s`
            name="flv2-$v-$a-$z"
            ffmpeg -i $videofile -acodec mp3 -ar $v -ab $a -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 "$v | $a | $z | $bytes ($hbytes) | $duration" >> results.wiki
            mv $name "$name-$duration.flv"
        done
    done
done

echo "||" >> results.wiki


Feel free to run your own tests and post your results here or append them as a comment

Page History
Date/CommentUserIPVersion
14 May 2009 (08:50 UTC)
Lester Caine81.138.11.13619
Current • Source
Lester Caine81.138.11.13618
View • Compare • Difference • Source
Lester Caine81.138.11.13617
View • Compare • Difference • Source
xing88.117.28.15616
View • Compare • Difference • Source
laetzer85.178.0.715
View • Compare • Difference • Source
Kozuch85.207.244.16014
View • Compare • Difference • Source
xing194.152.164.4512
View • Compare • Difference • Source
xing194.152.164.4511
View • Compare • Difference • Source
xing194.152.164.4510
View • Compare • Difference • Source
xing194.152.164.457
View • Compare • Difference • Source
xing194.152.164.456
View • Compare • Difference • Source
xing194.152.164.455
View • Compare • Difference • Source
xing194.152.164.454
View • Compare • Difference • Source
xing194.152.164.453
View • Compare • Difference • Source
xing194.152.164.452
View • Compare • Difference • Source
xing194.152.164.451
View • Compare • Difference • Source