FFMPEG integration
WebLancet can automatically convert uploaded video content to web-streaming ready media formats reaching such website behaviour as YouTube. Most popular are flv and h264 formats. h264 is a little harder to compile, but much better in compression ratio.
Principles of operation:
- User uploads any format video file
- WebLancet determines that it is convertable video file, grabs the
random frame for preview, and initiates ConversionJob subroutine that
converts file to FLV. File will be stored in Thumbnails directory, with
file ID and appropriate extension (flv/mp4)
Flash streaming is configured using those variables:
key=Toolkit,componentType=VideoToolkit (
PHPVideoToolkit; FFMpegPHP - depreciated)
key=PathToExecutable,componentType=FFMpeg (
ffmpeg;/usr/local/bin/ffmpeg;/usr/bin/ffmpeg) - path to FFMPEG binary.
key=VideoCodec,componentType=FFMpeg (flv;
libx264) - output video codec.
key=AudioCodec,componentType=FFMpeg (
libmp3lame; libfaac; any other codec, supported by ffmpeg) - output audio codec.
key=AudioSampleRate,componentType=FFMPEG(
44100; 22050;) - audio sample rate
key=UseSameVideoQualityAsSource,componentType=FFMpeg (
false,true)
key=ConstantQuality,componentType=FFMpeg (
false,true)
key=Params,componentType=FFMpeg_flv (
'-vcodec flv') - other conversion parameters (flv codec)
key=Params,componentType=FFMpeg_libx264 (
'-vcodec libx264 -y -level
41 -crf 25 -bufsize 20000k -g 250 -r 20 -rc_eq 'blurCplx^(1-qComp)'
-b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0') - other conversion parameters (libx264)
key=Preset,componentType=FFMpeg (
'medium') - libx264 encoding preset
Default settings are really cool and You shouldn't change them unless You really know what U are doing. Only if You are not too lazy to create the preset You should change "Preset" parameter to "golden".
Server setup
You can install FFMpeg to ubuntu server using this tutorial:
http://ubuntuforums.org/showthread.php?t=786095
You can prepare Your server for h264 pseudostreaming using this tutorial:
http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2
For best quality to size ratio, You can use a custom preset. Just create file
libx264-golden.ffpreset in /usr/local/share/ffmpeg (or just /usr/share/ffmpeg) and paste this content:
coder=1
flags=+loop
cmp=+chroma
partitions=+parti4x4+partp8x8+partb8x8
me_method=umh
subq=7
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=16
refs=2
directpred=3
trellis=0
flags2=+dct8x8+bpyramid
wpredp=2
This profile is based on results in this thread:
http://flowplayer.org/forum/7/12671