我正在尝试使用dash.js.播放破折号mpd文件。我使用axinom tutorial作为指导,建议使用以下命令生成mpd文件。
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothProfile.STATE_CONNECTED) {
isSending = false;
lastRecvData = null;
......
生成的mpd文件
mkdir dash_unprotected
MP4Box -dash 4000 -rap -frag-rap -sample-groups-traf -profile dashavc264:live
-bs-switching no -segment-name dash_$RepresentationID$_$Number$ -url-template
video-700k.mp4 video-1000k.mp4 video-1500k.mp4 video-2000k.mp4 audio.mp4 -out
"dash_unprotected/manifest.mpd"
然后我尝试使用下面的JavaScript代码在dash.js中播放它
<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.5.1-DEV-rev5619 on 2017-06-29T06:08:26Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500000S" type="static" mediaPresentationDuration="PT0H1M55.01S" profiles="urn:mpeg:dash:profile:isoff-live:2011, http://dashif.org/guildelines/dash264">
<ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
<Title>dash_unprotected/manifest.mpd generated by GPAC</Title>
</ProgramInformation>
<Period duration="PT0H1M55.01S">
<AdaptationSet segmentAlignment="true" maxWidth="316" maxHeight="576" maxFrameRate="30" par="316:576" lang="und">
<SegmentTemplate timescale="15360" media="dash_dash_unprotected$$Number$.m4s" startNumber="1" duration="49009" initialization="dash_dash_unprotected$init.mp4"/>
<Representation id="1" mimeType="video/mp4" codecs="avc1.64002a" width="158" height="288" frameRate="30" sar="396:395" startWithSAP="1" bandwidth="699969">
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.64002a" width="198" height="360" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="996926">
</Representation>
<Representation id="3" mimeType="video/mp4" codecs="avc1.64002a" width="264" height="480" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="1496279">
</Representation>
<Representation id="4" mimeType="video/mp4" codecs="avc1.64002a" width="316" height="576" frameRate="30" sar="396:395" startWithSAP="1" bandwidth="1993448">
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" lang="und">
<SegmentTemplate timescale="44100" media="dash_dash_unprotected$$Number$.m4s" startNumber="1" duration="174856" initialization="dash_dash_unprotected$init.mp4"/>
<Representation id="5" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="97798">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
但是dash.js会抛出错误
var url = "drm/dash_unprotected/manifest.mpd";
var player = dashjs.MediaPlayer().create();
$(function() {
player.initialize(document.querySelector("#videoPlayer"),null, true);
player.attachVideoContainer(document.getElementById("videoContainer"));
$('#playButton').click(function() {
player.attachSource(url);
});
});
我该如何解决这个错误?我是dash.js和mpeg-dash员工的新手
答案 0 :(得分:1)
我能够通过删除-segment-name
选项及其值来解决错误。所以我的命令看起来像这样
mkdir dash_unprotected
MP4Box -dash 4000 -rap -frag-rap -sample-groups-traf -profile dashavc264:live
-bs-switching no -url-template
video-700k.mp4 video-1000k.mp4 video-1500k.mp4 video-2000k.mp4 audio.mp4 -out
"dash_unprotected/manifest.mpd"
-segment-name
选项让我的片段互相覆盖。例如,由音频段覆盖的视频片段。
覆盖正在发生,因为即使我使用-segment-name
选项的唯一值,视频和音频片段也会被赋予相同的名称。
-segment-name $RepresentationID$$
或-segment-name $Time$$
取消此选项可使MP4Box对%s_dash
使用默认值-segment-name
。所以音频片段将被命名为
audio_dash1.m4s
和像这样的视频片段
`video_dash1.m4s`