I'm building a web app that should play back an RTSP/RTP stream from a server http://lscube.org/projects/feng.

Does the HTML5 video/audio tag support the rtsp or rtp? If not, what would the easiest solution be? Perhaps drop down to a VLC plugin or something like that.

upvote
  flag
upvote
  flag
video tag does not "just work" with RTSP. And RTSP is not implemented natively by any browser that I know of. You will either need a plug in, as you already figured out. Or use webRTC, which is natively supported by Chrome, and Firefox, and you will be able to use the video tag with some webRTC logic. If you're trying to stream from a source like an IP camera, use a streaming service like Wowza (or write your own) to transcode from RTSP to webRTC. This is my advice for you. – Michael P
upvote
  flag
I suggest to ask this question in StackOverflow for Multimedia Systems – Hamed
upvote
  flag
I think you can get stream with html5 but you can not stream to the somewhere. – Salih Karagoz

8 Answers 11

up vote 81 down vote accepted

Technically 'Yes'

(but not really...)

HTML 5's <video> tag is protocol agnostic—it does not care. You place the protocol in the src attribute as part of the URL. E.g.:

<video src="rtp://myserver.com/path/to/stream">
    Your browser does not support the VIDEO tag and/or RTP streams.
</video>

or maybe

<video src="http://myserver.com:1935/path/to/stream/myPlaylist.m3u8">
    Your browser does not support the VIDEO tag and/or RTP streams.
</video>

That said, the implementation of the <video> tag is browser specific. Since it is early days for HTML 5, I expect frequently changing support (or lack of support).

From the W3C's HTML5 spec (The video element):

User agents may support any video and audio codecs and container formats

45 upvote
  flag
@will824 w3schools is not a spec, it is a tutorial website by a private company. The spec is from the w3c itself, an international standards body. The HTML5 spec states "User agents may support any video and audio codecs and container formats." w3.org/TR/2008/WD-html5-20080122/#video0 – Stu Thompson
2 upvote
  flag
UPDATE: tried the first method in chrome and got GET rtp://239.255.0.1:6970 net::ERR_UNKNOWN_URL_SCHEME. It seems that only HTTP[S] schemes are allowed on video elements. – Yan Foto
upvote
  flag
Surely you would never transfer a video over HTTP and only use protocol like RTP? It would be terribly slow over TCP.. – markmnl
3 upvote
  flag
@markmnl Is that sarcasm? (I can't tell...I'm gullible that way.) HTTP transport is the dominate method for transferring video over the web for a few years now. Youtube, Netflix, et al. It's not a matter of efficiency, but rather simplicity, firewall transversal, cache server friendliness, etc. – Stu Thompson
upvote
  flag
Netflix streams video using HTTP?! No sarcasm just seems an inefficient way to stream video. – markmnl
5 upvote
  flag
@markmnl For posterity's sake, it's worth mentioning that Netflix used to stream with MS Silverlight, but ditched it a while back. As someone who's been in streaming since 2001, I was initially shocked to see HTTP take over. Now I'm drinking the Kool Aid. In corporate networks, where efficiency matters, purpose-built protocols RTP are the norm, especially when the can deliver features like multicast. – Stu Thompson

My observations regarding the HTML 5 video tag and rtsp(rtp) streams are, that it only works with konqueror(KDE 4.4.1, Phonon-backend set to GStreamer). I got only video (no audio) with a H.264/AAC RTSP(RTP) stream.

The streams from http://media.esof2010.org/ didn't work with konqueror(KDE 4.4.1, Phonon-backend set to GStreamer).

With VLC i'm able to transcode a live RTSP stream (mpeg4) to an HTTP stream in a OGG format (Vorbis/Theora). The quality is poor but the video work in Chrome 9. I have also tested with a trancoding in WEBM (VP8) but it's don't seem to work (VLC have the option but i don't know if it's really implemented for now..)

The first to have a doc on this should notify us ;)

1 upvote
  flag
How did you do this? – Johnydep
2 upvote
  flag
"C:\Program Files\VideoLAN\VLC\vlc.exe" -I dummy screen:// :screen-fps=16.000000 :screen-caching=100 :sout=#transcode{vcodec=theo,vb=800,scale=1,width=600,height‌​=480,acodec=mp3}:htt‌​p{mux=ogg,dst=127.0.‌​0.1:8080/desktop.ogg‌​} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep - this is VLC command which streams your input (e.g. screen capture device) to a given output stream (e.g. 127.0.0.1:8080/desktop.ogg) – Osi
1 upvote
  flag
and then you can embed this on a video tag: <video id="video" src="http://localhost:8080/desktop.ogg" autoplay="autoplay">. – Osi
2 upvote
  flag
But the performance is unfortunately pretty poor and would be great if it could also be done with MP4 container. AFAIK more browsers have support for MP4 than for OGG. – Osi
1 upvote
  flag
It worked for me too. I've set VLC for streaming both audio and video via HTTP protocol on my_ip:port adress and than I used HTML5 <video> tag like this: <video width="640"><source src="http://my_ip:port/test" type="video/ogg">HTML5 not supported</video>. – patryk.beza
upvote
  flag
can I make it work using JavaScript? – Manjeet Singh

Chrome will never implement support RTSP streaming.

At least, in the words of a Chromium developer here:

we're never going to add support for this

4 upvote
  flag
Well almost. Chrome already supports RTSP streaming, that's why he's never going to add support for this ;) – Stefan Steiger
2 upvote
  flag
No you can't get it working in chrome, It's not working when trying with youtube rtsp links. – IdidntKnewIt

The spirit of the question, I think, was not truly answered. No, you cannot use a video tag to play rtsp streams as of now. The other answer regarding the link to Chromium guy's "never" is a bit misleading as the linked thread / answer is not directly referring to Chrome playing rtsp via the video tag. Read the entire linked thread, especially the comments at the very bottom and links to other threads.

The real answer is this: No, you cannot just put a video tag on an html 5 page and play rtsp. You need to use a Javascript library of some sort (unless you want to get into playing things with flash and silverlight players) to play streaming video. {IMHO} At the rate the html 5 video discussion and implementation is going, the various vendors of proprietary video standards are not interested in helping this move forward so don't count of the promised ease of use of the video tag unless the browser makers take it upon themselves to somehow solve the problem...again, not likely.{/IMHO}

1 upvote
  flag
Good comment Golf. I wanted also to do what Elben is doing without success. – will824

Chrome not implement support RTSP streaming. An important project to check it WebRTC.

"WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs"

Supported Browsers:

Chrome, Firefox and Opera.

Supported Mobile Platforms:

Android and IOS

http://www.webrtc.org/

There are three streaming protocols / technology in HTML5:

Live streaming, low latency - WebRTC - Websocket

VOD and Live streaming, high latency - HLS

1. WebRTC

In fact WebRTC is SRTP(secure RTP protocol). Thus we can say that video tag supports RTP(SRTP) indirectly via WebRTC.

Therefore to get RTP stream on your Chrome, Firefox or another HTML5 browser, you need a WebRTC server which will deliver the SRTP stream to browser.

2. Websocket

It is TCP based, but with lower latency than HLS. Again you need a Websocket server.

3. HLS

Most popular high-latency streaming protocol for VOD(pre-recorded video).

1 upvote
  flag
How do you play a live audio+video stream using a web socket? The only way for video is using Broadway.js and that's pretty hacky using h264 nal streams. – mark gamache
upvote
  flag
HLS stands for HTTP Live Streaming, I wonder why HLS is widely used for VOD but not LOD? – shintaroid
upvote
  flag
You can't play a video in the web browser from WebSocket. At least not out of the box. – Michael IV

This is an old qustion, but I had to do it myself recently and I achieved something working so (besides response like mine would save me some time): Basically use ffmpeg to change the container to HLS, most of the IPCams stream h264 and some basic type of PCM, so use something like that:

ffmpeg -v info -i rtsp://ip:port/h264.sdp -c:v copy -c:a copy -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /var/www/html/test.m3u8

Then use video.js with HLS plugin This will play Live stream nicely There is also a jsfiddle example under second link).

Note: although this is not a native support it doesn't require anything extra on user frontend.

upvote
  flag
It worked for me, Videojs i was already using and this HLS plugin makes the live channel with m3u8 file work for most of urls, if not all. – Dheeraj Thedijje
upvote
  flag
Glad it helped, there is a bit more of a latency though, but that as it seems cannot be helped much. – Pawel K
upvote
  flag
I tried your sample but ffmpeg says "At least onde output file must be specified". Any ideas? – Cesar
1 upvote
  flag
Try this @Cesar: ffmpeg -v info -rtsp_transport tcp -i rtsp://host:port/[sdp] -c:v copy -c:a copy -maxrate 400k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /var/www/html/test.m3u8 – Pawel K
upvote
  flag
btw. I've tested it using ffmpeg 3.1.3 – Pawel K
upvote
  flag
Seems that worked. By the way, what do you use in server side to serve that .m3u8? It's being constantly feeded, seems that I can't just normal http to that. – Cesar
upvote
  flag
Well I've used a player like the one I've mentioned in the answer i.e. video.js + HLS Plugin referencing local file on the server, so I didn't expose m3u8 file to the web. I've used Apache2.2 as web server. – Pawel K
upvote
  flag
I forgot to add it will be fed constantly because it is live stream, but you can change it so it won't overwrite the files in cycles but I don't remember this now it is for sure in the -hls_xxxxx parameters I think if you omit -hls_wrap and -hls_time it would go indefinitely but I'm not sure I didn't research much in that direction – Pawel K
upvote
  flag
Nice solution, and not so CPU extensive compared to others I investigated. Thanks. – Deus777

Not the answer you're looking for? Browse other questions tagged or ask your own question.