RTSP streaming to Web App (Using VLC 2.0)

MasonWinsauer picture MasonWinsauer · Jun 11, 2012 · Viewed 11.5k times · Source

I am working on a web app that needs to display streaming video of a remote desktop. We have already implemented this using ffmpeg/ffserver and flowplayer, transcoding the RTSP into .flv format, but it is very fragile and my research has led me to using the command line version of VLC.

My question is: Is there a way to pipe transcoded RTSP (as OGG, RTP, or another format) into a browser while avoiding a reliance on flash?

I know that the tag hasn't supported streaming video for quite some time, but I'm having trouble finding consistent documentation. Some say you can pipe RTP directly in, some say you'll never be able to stream throuh the tag.

Also, I am currently testing all of this on my local Apache server.

I'm assuming the transcoding will look something along the lines of:

  • vlc -vvv rtsp://xx.xx.xx.xx:554/vga.sdp --no-sout-audio --sout '#standard{access=http,mux=ogg,dst=http://localhost/test_ogg.php}'

OR

  • vlc -vvv rtsp://xx.xx.xx.xx:554/vga.sdp --no-sout-audio --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=400}:duplicate{dst=display,dst=rtp{mux=ts,dst=xxx.xxx.xx.xx,port=xxxx}}'

Thanks - Mason

Answer

MasonWinsauer picture MasonWinsauer · Jul 18, 2012

Ok, so the solution that I was looking for came in the form of CVLC 2.0.1 [Console-only VLC], but also took advantage of the muxing capabilities of ffmpeg.

This one-liner transcodes the RTSP stream into FLV and pushes it to my localhost server at a specified port.

cvlc rtsp://xxx.xxx.xxx.xxx:554/vga.sdp :sout='#transcode{vcodec=FLV1,vb=2048,fps=25,scale=1,acodec=none,deinterlace}:http{mime=video/x-flv,mux=ffmpeg{mux=flv},dst=127.0.0.1:8090/device_1.flv}' :no-sout-standard-sap :ttl=5 :sout-keep :no-audio --video --no-sout-audio 

The advantages of this include not having to edit the ffserver.conf file each time the stream changes resolution, bit rate, frame rate, etc. - Only to restart this one line so that it can re-capture the stream. Also, if the stream has the proper specifications, you don't need the vb= and fps= properties; I would only use them if I needed to throttle the stream for the sake of the web page.

--network-caching was another feature that I was considering, though very useful in certain situations, unnecessary in my case.

The Flowplayer code looks something like:

<div style="width:1280px;height:720px;margin:10px" id="player_1"></div><script language="javascript">
flowplayer("player_1", {src: "/js/flowplayer-3.2.7.swf", wmode:"transparent"},{
clip: {
  url: 'http://127.0.0.1:8090/device_1.flv',
  autoPlay: true,
  autoBuffering: true,
  live: true,
  bufferLength:0
}, 
plugins: { 
   controls: { 
      all: false,
      scrubber: true,
      play: true, 
      fullscreen: true, 
      time: false,
      width: '100%',
      opacity: 0.8,
      tooltips: {
        buttons: true,
        fullscreen: 'Enter fullscreen mode'
    }
   }
} 
});

Hope this helps any viewers running into similar issues!

Mason