简体   繁体   中英

Dash.js do not play mpeg-dash from nginx rtmp module

I have nginx with rtmp plagin, i have test page with dash.js player. I need to stream mpeg-dash. I stream with ffmpeg, nginx process the stream, dash player try to play the stream, but dash.js start loop and request every 5 seconds .mpd file and show nothing.

I am use VLC player for test, its work perfect, that means problem in dash.js

 <!doctype html> <html> <head> <title>Dash.js Rocks</title> <style> video { width: 640px; height: 360px; } </style> </head> <body> <div> <video id="videoPlayer" controls></video> </div> <script src="dash.all.min.js"></script> <script> (function(){ var url = "http://localhost:8080/dash/test.mpd"; var player = dashjs.MediaPlayer().create(); player.initialize(document.querySelector("#videoPlayer"), url, true); })(); </script> </body> </html>

This is files from dash stream directory:

-rw-r--r--    1 nginx    nginx       120354 Jun 12 14:00 test-0.m4a
-rw-r--r--    1 nginx    nginx       526439 Jun 12 14:00 test-0.m4v
-rw-r--r--    1 nginx    nginx          599 Jun 12 14:00 test-init.m4a
-rw-r--r--    1 nginx    nginx          662 Jun 12 14:00 test-init.m4v
-rw-r--r--    1 nginx    nginx       292795 Jun 12 14:00 test-raw.m4a
-rw-r--r--    1 nginx    nginx       284084 Jun 12 14:00 test-raw.m4v
-rw-r--r--    1 nginx    nginx         2063 Jun 12 14:00 test.mpd

This is test.mpd:

<?xml version="3.0"?>
<MPD
    type="dynamic"
    xmlns="urn:mpeg:dash:schema:mpd:2011"
    availabilityStartTime="2016-06-12T13:59:55+00:00"
    availabilityEndTime="2016-06-12T14:00:31+00:00"
    minimumUpdatePeriod="PT5S"
    minBufferTime="PT5S"
    timeShiftBufferDepth="PT0H0M0.00S"
    suggestedPresentationDelay="PT10S"
    profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011"
    xmlns:xsi="http://www.w3.org/2011/XMLSchema-instance"
    xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
  <Period start="PT0S" id="dash">
    <AdaptationSet
        id="1"
        segmentAlignment="true"
        maxWidth="1380"
        maxHeight="800"
        maxFrameRate="15">
      <Representation
          id="test_H264"
          mimeType="video/mp4"
          codecs="avc1.640020"
          width="1380"
          height="800"
          frameRate="15"
          sar="1:1"
          startWithSAP="1"
          bandwidth="0">
        <SegmentTemplate
            presentationTimeOffset="0"
            timescale="1000"
            media="test-$Time$.m4v"
            initialization="test-init.m4v">
          <SegmentTimeline>
             <S t="0" d="6000"/>
             <S t="6000" d="16666"/>
             <S t="22666" d="11000"/>
             <S t="33666" d="2713"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet
 id="2"
        segmentAlignment="true">
      <AudioChannelConfiguration
          schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
          value="1"/>
      <Representation
          id="test_AAC"
          mimeType="audio/mp4"
          codecs="mp4a.40.2"
          audioSamplingRate="44100"
          startWithSAP="1"
          bandwidth="156000">
        <SegmentTemplate
            presentationTimeOffset="0"
            timescale="1000"
            media="test-$Time$.m4a"
            initialization="test-init.m4a">
          <SegmentTimeline>
             <S t="0" d="6000"/>
             <S t="6000" d="16666"/>
             <S t="22666" d="11000"/>
             <S t="33666" d="2713"/>
          </SegmentTimeline>
        </SegmentTemplate>`enter code here`
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

There is a good tutorial for NGINX + DASH at https://www.nginx.com/blog/scalable-live-video-streaming-nginx-plus-bitmovin , but it uses the bitmovin player instead of dash.js. I assume that dash.js hasn't implemented some features the NGINX DASH output uses. You could also test out Shaka player?.

You can have a try with below method. Put dash.all.min.js file under dash folder, and modify the dash.js like below.

<script src="http://localhost:8080/dash/dash.all.min.js"></script>

BR,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM