Playing RTMP stream with VideoJS player

21,522

If you wanna play RTMP you must include flash-tech which can be retrieved from here:

https://github.com/videojs/videojs-flash

Hence correct code would be this:

<head>
  <link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">

  <!-- If you'd like to support IE8 --> 
  <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>

<body>
  <video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
    <source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">                                                                                                                           
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>

  <script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
  <script src="/videojs-flash.js"></script>
</body>
Share:
21,522
NarūnasK
Author by

NarūnasK

Updated on July 19, 2020

Comments

  • NarūnasK
    NarūnasK almost 4 years

    I'm trying to play RTMP stream with VideoJS player, below is my code:

    <head>
      <link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">
    
      <!-- If you'd like to support IE8 --> 
      <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
    </head>
    
    <body>
      <video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
        <source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">                                                                                                                           
        <p class="vjs-no-js">
          To view this video please enable JavaScript, and consider upgrading to a web browser that
          <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
        </p>
      </video>
    
      <script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
    </body>
    

    The error I'm seeing is this:

    VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media. MediaError {code: 4, message: "No compatible source was found for this media."}

    The error is quite clear, but there are plenty of docs showing people success stories of playing RTMP streams with VideoJS:

    I know for sure that the following URL does play on VLC player and so does it on JWPlayer:

    rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov
    

    What could be the problem?

  • CharanRoot
    CharanRoot over 6 years
    i tried this example but its not working can you help me. i am not seeing any error in webconsole but video was not playing, i included videojs flash js file.
  • NarūnasK
    NarūnasK over 6 years
    Can you confirm that your RTMP stream is actually working, for instance can you play it with VLC player? If you comment out videojs-flash.js line, do you get any errors in the console? What are you using to stream RTMP? I was using Nginx plugin.
  • CharanRoot
    CharanRoot over 6 years
    I am able play video using VLC player. if i commented out videojs flash tag videojs returning MEDIA_ERR_SRC_NOT_SUPPORTED can you please check my code jsfiddle.net/qco58Lef Thanks.
  • NarūnasK
    NarūnasK over 6 years
    Unfortunately I have to confirm, that it doesn't work anymore.. A bug or incompatibility between projects, I don't know (as videojs-flash seem to be subdivision of videojs). BTW, in your jsfiddle you did not include videojs-flash.js.