gpt4 book ai didi

ffmpeg - Dash.js 不播放用 ffmpeg 制作的 mpd 文件

转载 作者:行者123 更新时间:2023-12-04 23:05:39 24 4
gpt4 key购买 nike

我正在使用 ffmpeg 创建要使用 Dash.js 实时流式传输的 webm 文件的 block 和 list 。不幸的是,无论我以哪种方式创建 block 和 list ,Dash.js 都不会播放 mpd 文件。但是,来自 Dash.js 的示例 mpd URL 可以正常工作。
命令

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
list 输出
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
list 文件 (glass_video_manifest.mpd)
我试图删除 ContetntComponent就像其他问题中建议的那样,但它没有用。
<?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>
Dash.js-播放器
<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>
Chrome
{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
更新
好吧,似乎一般的问题是 mpd 无法从该/dash 文件夹播放。所以我查看了代码,发现路由错误。无论如何,mpd 不会以我使用的给定命令开始,可能是因为它创建了一个 dynamic就像马库斯舒曼所说的那样。所以我要使用一个新的,它现在似乎正在工作,但不是很好。
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

最佳答案

您正在从文件创建实时 DASH 包,然后尝试从磁盘流式传输 DASH 包。
因此,您最终会得到一个 DASH list ,指示“实时”

<mpd
type="dynamic"
availabilityStartTime="2021-04-01T18:20:08Z"
虽然不是直播。所以 DASH.js 在试图找到你的“流”的实时边缘时会感到困惑。
如果您将属性从 type="dynamic"更改为 type='static' 并删除 availabilityStartTime - 您应该可以播放您的包。
一般来说:只有在您实际进行直播时才创建直播包。

关于ffmpeg - Dash.js 不播放用 ffmpeg 制作的 mpd 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66910316/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com