Dash.js不会从nginx rtmp模块播放mpeg-dash

时间:2016-06-12 14:05:33

标签: nginx stream rtmp mpeg-dash dash.js

我有rtmp plagin的nginx,我有带dash.js播放器的测试页面。我需要流mpeg-dash。我使用ffmpeg流,nginx处理流,dash播放器尝试播放流,但dash.js启动循环并请求每5秒.mpd文件并且不显示任何内容。

我使用VLC播放器进行测试,其工作完美,这意味着在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>

这是来自dash stream目录的文件:

-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

这是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>

1 个答案:

答案 0 :(得分:0)

https://www.nginx.com/blog/scalable-live-video-streaming-nginx-plus-bitmovin有一个很好的NGINX + DASH教程,但它使用的是bitmovin player而不是dash.js.我假设dash.js没有实现NGINX DASH输出使用的一些功能。您还可以测试Shaka播放器?