Crtmpserver
From Alessandro's Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
going "on-air"
- RTMP URL :
rtmp://[server address]/[application]/[streamName]
Mac/Win gui
- FMLE (Flash Media Live Encoder) http://www.adobe.com/products/flash-media-encoder.html
- Wirecast http://www.telestream.net/wire-cast/
Linux gui's
- unknown...
FFMPEG
ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
- play the stream:
ffplay "rtmp://myserver/live/mystream live=1"
-f mpegts udp://127.0.0.1:10000?pkt_size=1316 -f flv rtmp://127.0.0.1/live/myStream
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://127.0.0.1/live/video_stream1"
- FPS="15" # target FPS
- URL="rtmp://live.justin.tv/app/livestream" #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
Mplayer/Mencoder
- 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
- session
- 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
VLC
- 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=239.255.0.1:1234}" :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}}
JWplayer
- some may need this declarations in the .htaccess file:
AddType video/ogg .ogv AddType video/mp4 .mp4 AddType video/webm .webm
installation
Linux
- Tutorial for CentOS: http://wiki.rtmpd.com/tutorial_full_centos_build
- 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 https://svn.rtmpd.com/crtmpserver/branches/1.0 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 cmake -DCRTMPSERVER_INSTALL_PREFIX=/usr/local . 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/libssl.so /usr/lib/ ln -s /usr/lib/i386-linux-gnu/libcrypto.so /usr/lib/ ln -s /usr/lib/i386-linux-gnu/libdl.so /usr/lib/
configuration
- /opt/crtpmserver/configs
all.debug.lua flvplayback.lua run.bat run.sh users.lua
apps
- flash streamer application
/opt/crtpmserver/configs/flvplayback.lua
Problems
- 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)
firewall
- deamon opens the following sockets:
netstat -putan|grep crtmp tcp 0 0 0.0.0.0:6665 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:6666 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:1935 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:1111 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:1112 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:8988 0.0.0.0:* LISTEN 13841/crtmpserver tcp 0 0 0.0.0.0:8989 0.0.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
applications
- application files:
/usr/local/lib64/crtmpserver/applications/admin /usr/local/lib64/crtmpserver/applications/applestreamingclient /usr/local/lib64/crtmpserver/applications/appselector /usr/local/lib64/crtmpserver/applications/flvplayback /usr/local/lib64/crtmpserver/applications/proxypublish /usr/local/lib64/crtmpserver/applications/samplefactory /usr/local/lib64/crtmpserver/applications/stresstest /usr/local/lib64/crtmpserver/applications/vptests /usr/local/lib64/crtmpserver/applications/admin/libadmin.so /usr/local/lib64/crtmpserver/applications/applestreamingclient/libapplestreamingclient.so /usr/local/lib64/crtmpserver/applications/appselector/libappselector.so /usr/local/lib64/crtmpserver/applications/appselector/server.crt /usr/local/lib64/crtmpserver/applications/appselector/server.key /usr/local/lib64/crtmpserver/applications/flvplayback/libflvplayback.so /usr/local/lib64/crtmpserver/applications/flvplayback/mediaFolder /usr/local/lib64/crtmpserver/applications/flvplayback/users.lua /usr/local/lib64/crtmpserver/applications/proxypublish/libproxypublish.so /usr/local/lib64/crtmpserver/applications/samplefactory/libsamplefactory.so /usr/local/lib64/crtmpserver/applications/stresstest/libstresstest.so /usr/local/lib64/crtmpserver/applications/vptests/libvptests.so
client side
<!DOCTYPE html> <html> <head> <script> function init() { enableVideoClicks(); } 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() { videoNode.play(); }; }(videos[i])); } } </script> </head> <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="http://galalex.org:81/pr7.webm" type='video/webm; codecs="vp8, vorbis"'> --> <source src="http://galalex.org:81/743_7.webm" > <!-- <source src="http://galalex.org:81/963_1.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> --> <!-- <source src="pr6.ogv" type='video/ogg; codecs="theora, vorbis"'> --> </video> <script type='text/javascript' src='jwplayer.js'></script> <script type='text/javascript' > jwplayer("video_src1").setup({ file: "video_stream1", width: 320, height: 200, streamer: "rtmp://galalex.org/live", provider:"rtmp", allowscriptaccess:"always", autostart: 'true', stretching: "fill", provider: "rtmp" , image: "ColorBarsTT.jpg", repeat: 'always', events:{'onIdle': function(event) { jwplayer("video_src1").play();}}, flashplayer:"player.swf", }); </script> </body> </html>
references
- installing on Gentoo
http://foxpa.ws/2011/10/26/installing-c-rtmp-server-rtmpd-crtmpdserver-on-gentoo/
- using it
http://wiki.rtmpd.com/tutorial_live_stream_file
- documentation