Difference between revisions of "Red5"

From Alessandro's Wiki
Line 121: Line 121:
 
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Stream start
 
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Stream start
 
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect
 
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect
  +
  +
= flvstreamer =
  +
  +
http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/flvstreamer/README?root=flvstreamer
   
 
=Subscribe to stream via flash (JWPlayer)=
 
=Subscribe to stream via flash (JWPlayer)=

Revision as of 00:22, 22 May 2012

install

  • directory
/opt/red5

versions

  • 0.6.3
  • 0.8.0
  • 0.9.0
  • 0.9.1

config

plugin installer


admin interface

  1. http://localhost:5080/admin/register.html
  2. fill new user and password
  3. restart red5
  4. http://localhost:5080/demos/adminPanel.html

use

windows and mac

  • Adobe flash media live encoder

linux

where is what

  • SWF app: /opt/red5/webapps/root/demos/ofla_demo.swf
  • source code: /opt/red5/webapps/oflaDemo/WEB-INF/
  • streams: /opt/red5/webapps/oflaDemo/streams/


Install Xuggler

Red5 accepts "stream providers" in form of rtmp streams (or rtmps streams) to allow subscribers (rtmp clients) to view them. Xuggler adds rtmp support to ffmpeg.

Check ffmpeg version

In case you have installed ffmpeg before please check if it supports xuggler:

ffmpeg -i /invalid/file

Your output should look something like:

FFmpeg version SVN-r21606-xuggle-4.0.844, Copyright (c) 2000-2010 Fabrice Bellard, et al.
 built on Feb  2 2010 10:57:41 with gcc 4.4.1
 configuration: --prefix=/home/aclarke/Stage --extra-version=xuggle-4.0.844 --extra-cflags=-I/home/aclarke/Work/internal/xuggle/java/xuggle-xuggler/build/native/i686-pc-linux-gnu/captive/home/aclarke/Stage/include --extra-ldflags=-L/home/aclarke/Work/internal/xuggle/java/xuggle-xuggler/build/native/i686-pc-linux-gnu/captive/home/aclarke/Stage/lib --enable-shared --enable-gpl --enable-nonfree --enable-version3 --disable-stripping --disable-optimizations --disable-mmx --disable-mmx2 --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-pthreads
 libavutil     50. 8. 0 / 50. 8. 0
 libavcodec    52.51. 0 / 52.51. 0
 libavformat   52.50. 0 / 52.50. 0
 libavdevice   52. 2. 0 / 52. 2. 0
 libswscale     0. 9. 0 /  0. 9. 0
/invalid/file: no such file or directory

Make sure the --extra-version string above includes "xuggle" in it. If not, you have to continue with installation.

Install it really

Inspired by: http://www.youtube.com/watch?v=PuC_RKLotLE&feature=player_detailpage#t=150s

cd ~
mkdir xuggler-build
cd xuggler-build
http://com.xuggle.s3.amazonaws.com/xuggler/xuggler-3.4.FINAL/xuggle-xuggler.3.4.1012-src.tar.gz
tar -xzvf xuggle-xuggler.3.4.1012-src.tar.gz
export XUGGLE_HOME=/usr/local
export PATH=$XUGGLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$XUGGLE_HOME/lib/:$LD_LIBRARY_PATH
ant run-tests
# 600 bottles of beer later (see video)
ant run-tests
java -cp /usr/local/share/java/jars/xuggle-xuggler.jar com.xuggle.xuggler.demos.GetContainerInfo /home/westermann/video.flv

Now ffmpeg should support "rtmp":

westermann@westermann-desktop:~$ ffmpeg -protocols
FFmpeg version SVN-r21566-xuggle-3.4.843, Copyright (c) 2000-2010 Fabrice Bellard, et al.
  built on Apr 20 2011 13:43:47 with gcc 4.4.3
  configuration: --prefix=/usr/local --extra-version=xuggle-3.4.843 --extra-cflags=-I/home/westermann/Downloads/xuggler/build/native/x86_64-unknown-linux-gnu/captive/usr/local/include --extra-ldflags=-L/home/westermann/Downloads/xuggler/build/native/x86_64-unknown-linux-gnu/captive/usr/local/lib --enable-shared --enable-gpl --enable-nonfree --enable-version3 --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-pthreads
 libavutil     50. 8. 0 / 50. 8. 0
 libavcodec    52.49. 0 / 52.49. 0
 libavformat   52.48. 0 / 52.48. 0
 libavdevice   52. 2. 0 / 52. 2. 0
 libswscale     0. 9. 0 /  0. 9. 0
Supported file protocols:
file
gopher
http
pipe
rtmp
rtp
tcp
udp
...

Create the live stream to red5

This demo uses a static video file to test if we can stream to red5. In a real world example one would push a live stream to red5 by having a different source URL (-i).

ffmpeg -i /home/westermann/video.flv -f flv rtmp://127.0.0.1:1935/live/livestream

This will send the video.flv via rtmp to the local red5 to the application /live/ with the streamname "livestream". You should read more about ffmpeg to find out the right parameters for your streaming video.

Red5 will tell something like:

[DEBUG] [NioProcessor-1] org.red5.server.Scope - Add child: org.red5.server.stream.BroadcastScope@adb24
[DEBUG] [NioProcessor-1] org.red5.server.Scope - Add child scope: org.red5.server.stream.BroadcastScope@adb24 to [WebScope@79a422d9 Depth = 1, Path = '/default', Name = 'live']
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Stream start
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect

flvstreamer

http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/flvstreamer/README?root=flvstreamer

Subscribe to stream via flash (JWPlayer)

It should be possible to view this live stream now with a JWPlayer with the following integration. This is a only for testing, JWPlayer integration could be done better (e.g. with option for HTML5).

player.html:

 ...
 <script type="text/javascript" src="/somepath/swfobject.js"> 
 </script> 
 <div class="flash420"> 
 <div id="player"> 
 Unfortunately you don't have Adobe Flash-Player....
 <a href="http://get.adobe.com/flashplayer/">Klicken Sie hier für den kostenlosen Adobe Flash-Player.</a> 
 </div><script type="text/javascript"> 
  var flashvars = {
          file:'livestream',
          streamer:'rtmp://10.70.136.1/live/',
          image:'/somepath/millennium_1.jpg',
          bufferlength:'2',
          backcolor:'#000000',
          frontcolor:'#166EBA',
          screencolor:'#999999',
          lightcolor:'#990000',
          autostart:'false',
          repeat:'none',
          stretching:'',
          playlist:'bottom',
          playlistsize:'160',
 
        };
  var params = { allowfullscreen:'false', allowscriptaccess:'always', wmode:'transparent' };
  var attributes = { id:'player1', name:'player1' };
  swfobject.embedSWF('/somepath/player-licensed-5.2.swf','player','384','468','9.0.0','false',flashvars, params, attributes);
 </script> 
 </div> 
 ...