How to Stream an SDP RTSP Feed with Javascript


Firstly, let me say that I explored the HTML5 video tag in an attempt to achieve just this and had no success. Apparently Safari does support the video tag source to be an RTP stream (allegedly, I have not tested this), but it does not work for RTSP. I know this because I’ve tried it myself, so here’s the Javascript code to display an RTSP stream. You will need an Apple Javascript library file which can be found here. If the link does not work, comment it please, and I’ll update :). Here’s the code:

QT_WriteOBJECT(‘img/logo.png’,’640′,’496′,”,
‘href’,’rtsp://yourdomain.com:554/denver.sdp’,
‘target’,’myself’,
‘controller’,’false’,
‘autoplay’,’true’
);

Please be aware that there must be a legitimate image for the poster image. For some reason, the autoplay parameter will be ignored, my theory behind this is autoplay is only supported with mp4 or mov files and not streaming files. This must be enclosed in script tags and it should be put in the body of an html document.

Wherever you place the code is where the object will appear. For some reason I had no luck in running this in Firefox, this is probably because the particular stream I was using used the H.264 codec which Mozilla is apparently prohibited to use because of its open-source nature. However, it worked well in Safari and in Chrome.

About these ads

About coderepo

PHP Developer
This entry was posted in Javascript and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s