Reputation: 81
I'm using ffmpeg to create chunks and manifest of a webm file which I want to live stream with Dash.js. Unfortunately Dash.js won't play the mpd file, no matter which way I create the chunks and manifest. However, the sample mpd URL from Dash.js is working.
ffmpeg -re -r 25 -i Dash/strm.webm
-map 0:v:0
-pix_fmt yuv420p
-c:v libvpx
-s 640x480 -keyint_min 60 -g 60 -speed 6 -tile-columns 4 -frame-parallel 1 -threads 8 -static-thresh 0 -max-intra-rate 300 -deadline realtime -lag-in-frames 0 -error-resilient 1
-b:v 3000k
-f webm_chunk
-header "Dash/glass_360.hdr"
-chunk_start_index 1 Dash/glass_360_%d.chk
-map 0:a:0
-c:a libvorbis
-b:a 128k -ar 44100
-f webm_chunk
-audio_chunk_duration 2000
-header Dash/glass_171.hdr
-chunk_start_index 1 Dash/glass_171_%d.chk
//Manifest
ffmpeg
-f webm_dash_manifest -live 1
-i Dash/glass_360.hdr
-f webm_dash_manifest -live 1
-i Dash/glass_171.hdr
-c copy
-map 0 -map 1
-f webm_dash_manifest -live 1
-adaptation_sets "id=0,streams=0 id=1,streams=1"
-chunk_start_index 1
-chunk_duration_ms 2000
-time_shift_buffer_depth 7200
-minimum_update_period 7200 Dash/glass_video_manifest.mpd
ffmpeg version git-2020-05-27-8b5ffae Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 49.100 / 56. 49.100
libavcodec 58. 87.101 / 58. 87.101
libavformat 58. 43.100 / 58. 43.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 83.100 / 7. 83.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, webm_dash_manifest, from 'Dash/glass_360.hdr':
Metadata:
ENCODER : Lavf58.43.100
Duration: N/A, bitrate: N/A
Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
Metadata:
ALPHA_MODE : 1
ENCODER : Lavc58.87.101 libvpx
webm_dash_manifest_file_name: glass_360.hdr
webm_dash_manifest_track_number: 1
Input #1, webm_dash_manifest, from 'Dash/glass_171.hdr':
Metadata:
ENCODER : Lavf58.43.100
Duration: N/A, bitrate: N/A
Stream #1:0(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
Metadata:
ENCODER : Lavc58.87.101 libvorbis
webm_dash_manifest_file_name: glass_171.hdr
webm_dash_manifest_track_number: 1
Output #0, webm_dash_manifest, to 'Dash/glass_video_manifest.mpd':
Metadata:
encoder : Lavf58.43.100
Stream #0:0(eng): Video: vp8, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 1k tbr, 1k tbn, 1k tbc (default)
Metadata:
ALPHA_MODE : 1
ENCODER : Lavc58.87.101 libvpx
webm_dash_manifest_file_name: glass_360.hdr
webm_dash_manifest_track_number: 1
Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
Metadata:
ENCODER : Lavc58.87.101 libvorbis
webm_dash_manifest_file_name: glass_171.hdr
webm_dash_manifest_track_number: 1
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: unknown
Manifest file
(glass_video_manifest.mpd)
I tried to delete the ContetntComponent
like suggested in other questions, but it didn't work.
<?xml version="1.0" encoding="UTF-8"?>
<MPD
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:DASH:schema:MPD:2011"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011"
type="dynamic"
minBufferTime="PT1S"
profiles="urn:mpeg:dash:profile:isoff-live:2011"
availabilityStartTime="2021-04-01T18:20:08Z"
timeShiftBufferDepth="PT7200S"
minimumUpdatePeriod="PT7200S">
<Period id="0" start="PT0S" >
<AdaptationSet id="0" mimeType="video/webm" codecs="vp8" lang="eng" bitstreamSwitching="true" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<ContentComponent id="1" type="video"/>
<SegmentTemplate timescale="1000" duration="2000" media="glass_$RepresentationID$_$Number$.chk" startNumber="1" initialization="glass_$RepresentationID$.hdr"/>
<Representation id="360" bandwidth="1000000" width="640" height="480" codecs="vp8" mimeType="video/webm" startsWithSAP="1"></Representation>
</AdaptationSet>
<AdaptationSet id="1" mimeType="audio/webm" codecs="vorbis" lang="eng" bitstreamSwitching="true" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<ContentComponent id="1" type="audio"/>
<SegmentTemplate timescale="1000" duration="2000" media="glass_$RepresentationID$_$Number$.chk" startNumber="1" initialization="glass_$RepresentationID$.hdr"/>
<Representation id="171" bandwidth="128000" audioSamplingRate="44100" codecs="vorbis" mimeType="audio/webm" startsWithSAP="1"></Representation>
</AdaptationSet>
</Period>
</MPD>
<script>
(function(){
// var url = "https://dash.akamaized.net/envivio/EnvivioDash3/manifest.mpd";
var url = "http://localhost:8081/videos/Dash/glass_live_manifest.mpd";
var player = dashjs.MediaPlayer().create();
// config
targetLatency = 2.0; // Lowering this value will lower latency but may decrease the player's ability to build a stable buffer.
minDrift = 0.05; // Minimum latency deviation allowed before activating catch-up mechanism.
catchupPlaybackRate = 0.5; // Maximum catch-up rate, as a percentage, for low latency live streams.
stableBuffer = 2; // The time that the internal buffer target will be set to post startup/seeks (NOT top quality).
bufferAtTopQuality = 2; // The time that the internal buffer target will be set to once playing the top quality.
player.updateSettings({
'streaming': {
'liveDelay': 2,
'liveCatchUpMinDrift': 0.05,
'liveCatchUpPlaybackRate': 0.5,
'stableBufferTime': 2,
'bufferTimeAtTopQuality': 2,
'bufferTimeAtTopQualityLongForm': 2,
'bufferToKeep': 2,
'bufferAheadToKeep': 2,
'lowLatencyEnabled': true,
'fastSwitchEnabled': true,
'abr': {
'limitBitrateByPortal': true
},
}
});
console.log(player.getSettings());
setInterval(() => {
console.log('Live latency= ', player.getCurrentLiveLatency());
console.log('Buffer length= ', player.getBufferLength('video'));
}, 3000);
player.initialize(document.querySelector("#videoPlayer"), url, true);
})();
</script>
{debug: {…}, streaming: {…}}
dash.all.min.js:2 XHR finished loading: GET "http://localhost:8081/videos/Dash/glass_live_manifest.mpd".
load @ dash.all.min.js:2
C @ dash.all.min.js:2
load @ dash.all.min.js:2
load @ dash.all.min.js:2
load @ dash.all.min.js:2
load @ dash.all.min.js:2
se @ dash.all.min.js:2
te @ dash.all.min.js:2
initialize @ dash.all.min.js:2
(anonymous) @ Dash:92
(anonymous) @ Dash:94
DevTools failed to load SourceMap: Could not parse content for http://localhost:8081/js/dash.all.min.js.map: Cannot read property 'length' of undefined
Dash:88 Live latency= NaN
Dash:89 Buffer length= NaN
Dash:88 Live latency= NaN
Dash:89 Buffer length= NaN
Dash:88 Live latency= NaN
Dash:89 Buffer length= NaN
Dash:88 Live latency= NaN
Dash:89 Buffer length= NaN
Dash:88 Live latency= NaN
Dash:89 Buffer length= NaN
Well, it seems like the problem in general was, that the mpd's wouldn't play from that /dash folder. So i took a look into the code and found a bad routing. Anyways, the mpd would't start with the given command I used, probably becasue it creates a dynamic
manifest, like @Markus Schumann says. So I'm going with a new one which seems to be working for now, but not very well.
ffmpeg -y -re -i strm.webm
-c:v libx264 -x264opts "keyint=24:min-keyint=24:no-scenecut"
-r 24 -c:a aac -b:a 128k -bf 1 -b_strategy 0 -sc_threshold 0 -pix_fmt yuv420p
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -b:v:0 250k
-filter:v:0 "scale=-2:240" -profile:v:0 baseline -b:v:1 750k
-filter:v:1 "scale=-2:480" -profile:v:1 main -b:v:2 1500k
-filter:v:2 "scale=-2:720" -profile:v:2 high
-use_timeline 1 -use_template 1 -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a"
-f dash glass_video_manifest.mpd
Upvotes: 0
Views: 3075
Reputation: 8264
You are creating a live DASH package from a file and then you try to stream your DASH package from disk. So you end up with a DASH manifest indicating 'live'
<mpd
type="dynamic"
availabilityStartTime="2021-04-01T18:20:08Z"
although it is not live. So DASH.js gets confused trying to find the live edge of your "stream".
if you change the attribute from type="dynamic" to type='static' and remove availabilityStartTime - you should be able to play your package.
In general: only create a live package if you are actually live streaming.
Upvotes: 3