Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stream video with rtmp and videojs

I looking for a way to stream play videos with rtmp. I use video-js but it doesn't work. Firebug return an error :

L'attribut « type » spécifié sur « video/flash » n'est pas géré. Le chargement de la ressource média rtmp://server.com/vod/mp4:foo/bar/my_video.mp4 a échoué.
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this video. MediaError { code=4,  message="No compatible source was found for this video."

HTML code :

<!doctype html>
<html lang="fr" class="no-js">
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
   <link rel="stylesheet" href="css/reset.css"> <!-- CSS reset -->
   <link rel="stylesheet" href="css/video-js.css"> <!-- Video.js -->
   <link rel="stylesheet" href="css/style.css"> <!-- Resource style -->
   <script src="js/modernizr.js"></script> <!-- Modernizr -->
   <title>Title</title>
</head>
<body class="sous-menu">
  <video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
    controls preload="auto" width="640" height="264"
    data-setup='{"techOrder": ["flash", "html5"]}'>
    <source src="rtmp://server.com/vod/mp4:foo/bar/my_video.mp4" type='rtmp/mp4' />
  </video>
   <script src="js/jquery-2.1.4.min.js"></script> <!-- jQuery -->
   <script src="js/video-js.js"></script> <!-- Videojs.js -->
</body>
</html>

What I'm doing wrong ?

Edit: I add the type='rtmp/mp4' but it still dosen't work ... Test in FF, Chrome & IE11. Tried the link in VLC and it work.

like image 875
Snabow Avatar asked Nov 26 '15 14:11

Snabow


People also ask

Is RTMP outdated?

RTMP was originally designed for streaming with Adobe's Flash player and is often simply called Flash streaming, but this use is now quite outdated.

Can VLC stream to RTMP?

The best answer is VLC. According to the official VLC team, VLC supports RTMP and rtmp:// URLs from version 1.1 and onwards. If you have received an RTMP link, you can still use VLC to open the RTMP stream.

Can you live stream YouTube through an RTMP link?

1 Check for a YouTube RTMPS preset Update your encoder to the newest version and check for a built-in setting for YouTube RTMPS. If you see a YouTube RTMPS preset, select it. You may need to enter your stream key from Live Control Room too. You're now ready to stream.


2 Answers

Use the type rtmp/mp4 in your source. Also, video.js uses an ampersand to separate the server URL and stream name. RTMP will only work where Flash is available of course.

<source src='rtmp://server.com/vod/&mp4:foo/bar/my_video.mp4' type='rtmp/mp4'/>
like image 74
misterben Avatar answered Oct 14 '22 13:10

misterben


You might want to ensure you are returning the correct content-type on the server. See: https://github.com/videojs/video.js/issues/1994

like image 28
Broonix Avatar answered Oct 14 '22 14:10

Broonix