wtorek, 17 maja 2011

VLC + p2p real time audio/video streaming

Recently I was coordinating this art event. My responsibility was to setup real-time a/v streams in five cities. Every city was streaming a/v from hd camera and also realy big projector was showing streams from other cities. We decided to go for p2p architecture and use some additional player which can randomly switch streams.

We decided to use VLC ...and first bummer: Vlc dosen't support grabbing video from firewire (or I wasn't able to find this option in UI). We are sure we don't want to put ieee 1394 as v4l device, because only way to do that is by vloopback - and this module... well it isn't quite stable.

This line was used to setup stream with transcoding it by h264.

dvgrab - -noavc -nostop | cvlc - -vvv --no-sub-autodetect-file :demux=rawdv
--sout'#transcode{vcodec=h264,vb=600,acodec=mp3,ab=56,scale=0,width=720,height=576,channels=2}:
duplicate{dst=std{access=http,mux=ts,dst=0.0.0.0:8085}}'

also stream tittle is a neat feature:

#transcode{vcodec=h264,vb=1500,scale=1,width=1024,height=576,
sfilter='marq{marquee=Toruń %Y/%m/%d%H:%M%S,position=10,size=14}',
acodec=mp3,ab=196,channels=2,samplerate=44100}:http{mux=ts,dst=:8081/}

stream merging was achieved by

cvlc url1:port url2:port ... --sout="#gather:http{mux=ts,dst=localhost:8079/}" --sout-keep


this will loopback merged stream to localhost on 8079, just open it in any player and switch streams by vlc ui. Depending on option http-cache (buffer size) switching will be little bit delayed (but this is what we wanted to achieve here). Also notice that --sout-keep will only work if stream config is identicall, so you have two option: transocde it on the client or make same setup on server.

Look also here: auto-reconnect, and someone advised me to take a look on twisted-based streaming software

Brak komentarzy: