Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play rtmp live stream using videojs?

I'm using OBS to push live stream to my local rtmp server(node-rtsp-rtmp-server), and it works well with VLC media player. I just want to put it into a webpage and i found videojs. It didnt work and returns Specified “type”-attribute “rtmp/mp4” is not supported. it seems my rtmp server didnt reveive any requests from this webpage. So what i missed? here is my code:

<head>
    <meta charset="utf-8">
    <link href="./video-js-6.0.0/video-js.css" rel="stylesheet">
    <script src="./video-js-6.0.0/video.js"></script>
    <script src="./video-js-6.0.0/videojs-flash.min.js"></script>
    <script>
        videojs.options.flash.swf = "./video-js-6.0.0/video-js.swf"
    </script>
</head>
<body>
   <video  id='vid' class='video-js' controls height=300 width=600>
      <source src="rtmp://127.0.0.1:1935/live/pokemon" type="rtmp/mp4"/>
    </video>
    <script>
        var player = videojs('vid');
    </script>
</body>
like image 271
Natsu Avatar asked Apr 07 '17 06:04

Natsu


People also ask

How do I watch an RTMP stream?

On the top menu bar, click “Media” > “Open Network Stream…” or press “Ctrl + N.” 3. At the window that appears, enter an RTMP URL in the format “rtmp://Server URL/live/Stream Name” at the URL box, and hit “Play.” The stream will start in a few seconds.

Can VLC send RTMP?

VLC supports RTMP and rtmp:// URLs as of version 1.1, through the avio module via the libavformat library.


1 Answers

To publish a stream from a RTMP server to a web page, you have 2 options:

  1. embed RTMP stream in a Flash player (Strobe, JwPlayer, FlowPlayer)
  2. deliver stream in a HTML5 format (HLS or MPEG DASH) using a streaming server that supports that like Wowza Streaming Engine; this may also require transcoding if your stream is not already encoded with H264 and AAC
like image 155
TopReseller Avatar answered Sep 27 '22 21:09

TopReseller