From Alessandro's Wiki
Jump to navigation Jump to search

going "on-air"

  • RTMP URL :
rtmp://[server address]/[application]/[streamName]

Mac/Win gui

Linux gui's

  • unknown...


ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  • play the stream:
ffplay "rtmp://myserver/live/mystream live=1"
-f mpegts udp://
-f flv rtmp://
ffmpeg -i /home/mediacluster/mediaroot/video/269_5.mp4 -re -vcodec flv -b:v 500k -s 320x200 -strict experimental -g 25  -me_method zero          -acodec aac -ab 128k -ar 48000 -ac 2 -f flv "rtmp://"
  • FPS="15" # target FPS
  • URL="rtmp://" #flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"
ffmpeg -f x11grab -s 720x576 -r "$FPS" -i :0.0  -ab 96k \
   -f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 -preset fast -s "320x200" \
   -acodec libmp3lame -ar 44100 -threads 0 \
   -f flv "$URL"
ffmpeg -re -i /home/mediacluster/mediaroot/video/269_2.flv -f flv -metadata streamName="video_stream1" "tcp://localhost:6666"
ffmpeg  -f video4linux2 -s 720x576 -i /dev/video2  -f flv -metadata streamName="video_stream2" "tcp://localhost:6666"
ffmpeg  -f video4linux2 -r 10 -s 640x360 -i /dev/video0  -f flv -metadata streamName="video_stream3" "tcp://localhost:6666"
ffmpeg  -f video4linux2 -r 10 -s 640x360 -i /dev/video1  -f flv -metadata streamName="video_stream4" "tcp://localhost:6666"
  • ffmpeg
Capture from composite or S-video
ffmpeg -async 12 -vd /dev/video -ad /dev/dsp -f avi -r 25 -s 720x576 -croptop 8 -cropbottom 8 -cropleft 8 \
-cropright 8 -sameq -aspect 4:3 -acodec mp2 -ac 2 -ab 224k -ar 48000 -y -t 04:30:00 outfile.avi

ffmpeg -threads 2 -vd /dev/video$DEV -r 29.97 -b 800 -s 640x480 -vcodec h264 -qmax 51 \
-me epzs -deinterlace -g 300 -async 1 -ac 2 -acodec mp3 -ab 96 -ar 32000 \
-ad /dev/dsp$DEV -t $TIM -f avi -y $DIR/$FIL.avi


    • socks=host:port
    • app=name
    • tcUrl=url
    • pageUrl=url
    • swfUrl=url
    • flashVer=version
    • conn=type:data
      • Append arbitrary AMF data to the Connect message. The type must be B for Boolean, N for number, S for string, O for object, or Z for null. For Booleans the data must be either 0 or 1 for FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or 1 to end or begin an object, respectively. Data items in subobjects may be named, by prefixing the type with 'N' and specifying the name before the value, e.g. NB:myFlag:1. This option may be used multiple times to construct arbitrary AMF sequences. E.g.
    • conn=B:1 conn=S:authMe conn=O:1 conn=NN:code:1.23 conn=NS:flag:ok conn=O:0
    • playpath=path
    • playlist=0|1
    • live=0|1
       Specify that the media is a live stream. No resuming or seeking in live streams is possible. 
    • subscribe=path
    • start=num
    • stop=num
    • buffer=num
    • timeout=num
mencoder -tv driver=v4l2:device=/dev/video$DEV:fps=30000/1001:chanlist=us-bcast:\
audiorate=32000:adevice=/dev/dsp$DEV:input=0:amode=1:normid=4:width=512:height=384 \
-ovc x264 -x264encopts threads=2:bitrate=800:subq=2:me=2:frameref=4:8x8dct \
-oac mp3lame -lameopts cbr:br=96 -endpos $TIM -o $DIR/$FIL.avi tv:// > /dev/null


  • rtmp server
vlc input.flv --sout '#transcode{vcodec=FLV1,acodec=mp3}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=localhost:1936/live/video_stream1}'
  • UDP multicast
vlc input.mp4 --sout="#std{access=udp,mux=ts,dst=}" :sout-all
  • something...
vlc -I dummy -vvv rtsp://<RTSP Stream of CRTMP server> vlc://quit --sout=#duplicate{dst=std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=c:/nginx-1.0.3/html/live/mystream.m3u8,index-url=http://<IP of Webserver>/live/mystream-########.ts},mux=ts{use-key-frames},dst=c:/nginx-1.0.3/html/live/mystream-########.ts},dst=std{access=http,mux=ts,dst=:8090/video.mp4}}


  • some may need this declarations in the .htaccess file:
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm



  • I will build the software in /opt/crtmpserver and install it in /server
  • download source (UPDATE 11/2015, server is down)
svn co --username anonymous crtmpserver
  • some dependencies:
yum install cmake openssl-devel
apt-get install subversion libssl-dev cmake g++ libtinyxml-dev libtinyxml2-dev libsslcommon2-dev
  • do compile the source specifying the prefix you want, /usr/local is the default
cd builders/cmake
make install
  • now let's go in /usr/local/etc/ and use crtmpserver.lua.sample to generate your crtmpserver.lua changing the rootDirectory=" variable in applications= { /usr/local/lib/crtmpserver/applications
  • install the certificates:
cp /opt/crtmpserver/builders/cmake/applications/appselector/server.* /usr/local/lib/crtmpserver/applications/appselector/
  • link your own media directory (in this case I'm linking the Videos directory located in my home) to the player application media foder:
ln -s ~/Videos /usr/local/lib/crtmpserver/applications/flvplayback/mediaFolder
cp /opt/crtmpserver/builders/cmake/applications/flvplayback/users.lua /usr/local/lib/crtmpserver/applications/flvplayback/

  • it should be possible now to execute the compiled and configured program
  • UPDATE 11/ 2015 (GCC > 4.6)
  • needed to do this sloppy-job to be able to compile, but I'm sure there's a cleaner way.
ln -s /usr/lib/i386-linux-gnu/ /usr/lib/
ln -s /usr/lib/i386-linux-gnu/ /usr/lib/
ln -s /usr/lib/i386-linux-gnu/ /usr/lib/


  • /opt/crtpmserver/configs


  • flash streamer application


  • sometimes the server gets stuck and when one tries to start the streaming it fails with a server error (even though the connection to the server works)
1448549708:3:/opt/crtmpserver/sources/thelib/src/application/baseclientapplication.cpp:227:SignalStreamRegistered:Stream NR(76) with name `` registered to application `flvplayback` from protocol IR(75)
1448549708:2:/opt/crtmpserver/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:776:ProcessInvokePublish:Stream name livestream?videoKeyframeFrequency=5&totalDatarate=746 already occupied and application doesn't allow duplicated inbound network streams
1448549708:3:/opt/crtmpserver/sources/thelib/src/application/baseclientapplication.cpp:238:SignalStreamUnRegistered:Stream NR(76) with name `` unregistered from application `flvplayback` from protocol IR(75)


  • deamon opens the following sockets:
netstat -putan|grep crtmp
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver   
tcp        0      0      *                   LISTEN      13841/crtmpserver  
  • so a generic iptables configuration could be this:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1935 -j ACCEPT 
-A INPUT -p udp -m state --state NEW -m tcp --dport 8080 -j ACCEPT 


  • application files:

client side

<!DOCTYPE html>
    function init() {

    function enableVideoClicks() {
      var videos = document.getElementsByTagName('video') || [];
      for (var i = 0; i < videos.length; i++) {
        // TODO: use attachEvent in IE
        videos[i].addEventListener('click', function(videoNode) {
          return function() {
 <body onload="init()" style="margin:0px;position:relative;" >

        <video width=320 height=200 controls  preload="none" autobuffer poster="ColorBarsTT.jpg" >
        Your browser does not support the VIDEO tag and/or RTP streams.
<!--            <source src="" type='video/webm; codecs="vp8, vorbis"'> -->
                <source src="" >
                <!-- <source src=""  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> -->
                <!-- <source src="pr6.ogv"  type='video/ogg; codecs="theora, vorbis"'>  -->

  <script type='text/javascript' src='jwplayer.js'></script>
  <script type='text/javascript' >

        file:   "video_stream1",
        width:  320,
        height: 200,
        streamer:  "rtmp://",
        autostart:      'true',
        stretching:     "fill",
        provider:       "rtmp" ,
        image:          "ColorBarsTT.jpg",
        repeat:         'always',
        events:{'onIdle': function(event) {      jwplayer("video_src1").play();}},


  • installing on Gentoo

  • using it

  • documentation