我正在尝试从一个静态文件创建一个MPEG-破折号“活”流来测试各种低延迟模式。FFmpeg中的DASH muxer创建了两个AdaptationSets,一个用于视频块,另一个用于音频块。
但是,音频和视频块文件的创建速度并不相同(应该是这样吗?)在这里,stream0是视频块,stream1是音频块。运行几秒钟后,webroot目录包含:
chunk-stream0-00001.m4s chunk-stream1-00001.m4s
chunk-stream0-00002.m4s chunk-stream1-00002.m4s
chunk-stream0-00003.m4s chunk-stream1-00003.m4s
chunk-stream0-00004.m4s chunk-stream1-00004.m4s
chunk-stream1-00005.m4s
chunk-stream1-00006.m4s
chunk-stream1-00007.m4s
chunk-stream1-00008.m4s
chunk-stream1-00009.m4s
master.mpd
init-stream0.m4s
init-stream1.m4s 该流不会在dash.js或shaka-player上加载(或播放),而且对于视频块有很多404 (Not Found)错误。播放机正在按顺序请求来自stream0和stream1的块,即stream0-001 + stream1-001,然后stream0-002 + stream1-002等等。
但是,由于stream0只从001到004,所以当它尝试加载流0-005到009时,会出现大量的404错误。
在让FFmpeg运行了一段时间之后,差距变得更大了。stream0是62比75,stream1是174比187。此时重新加载播放机页面将使用dash.all.debug.js:15615 [2055][FragmentController] No video bytes to push or stream is inactive.失败,并显示404个错误stream0块188 (还不存在!)

FFmpeg命令是从破折号从上到下流采用的
ffmpeg -re -i /mnt/swdevel/TestStreams/H264/ThreeHourMovie.mp4 \
-c:v libx264 -x264-params keyint=120:scenecut=0 -b:v 1M -c:a copy \
-f dash -dash_segment_type mp4 \
-seg_duration 2 \
-target_latency 3 \
-frag_type duration \
-frag_duration 0.2 \
-window_size 10 \
-extra_window_size 3 \
-streaming 1 \
-ldash 1 \
-use_template 1 \
-use_timeline 0 \
-write_prft 1 \
-fflags +nobuffer+flush_packets \
-format_options "movflags=+cmaf" \
-utc_timing_url "/pelican/testPlayers/time.php" \
master.mpddash.js播放器代码非常简单:
const srcUrl = "../ottWebRoot/playerTest/master.mpd";
var player = dashjs.MediaPlayer().create();
let autoPlay = false;
player.initialize(document.querySelector("#videoTagId"), srcUrl, autoPlay);
player.updateSettings(
{
streaming :
{
lowLatencyEnabled : true,
liveDelay : 2,
jumpGaps : true,
jumpLargeGaps : true,
smallGapLimit : 1.5,
}
});为了在清单中提供UTCTiming元素,time.php小URL从web服务器返回一个UTC时间:
<?php
print gmdate("Y-m-d\TH:i:s\Z");
?>(它还显示了最新的流1/音频块的404个错误,这可能是另一个问题)
我不知道下一步该做什么。任何建议和建议都非常感谢。
编辑I
@匿名考沃德提出的改变关键区间的建议大大改善了情况。stream0和stream1的块处于锁定步态,具有相同的序列号.
然而,仍然有许多404错误,无论是在初始页面加载(没有按下播放)还是在播放过程中。
我运行watch -n 1 ls -lt <webRootFolder并将其与浏览器控制台中的错误并行进行比较。这是很难比较的,但看起来浏览器正在尝试获取“游戏边缘”中尚未由FFmpeg创建的文件。见下面的图片。
如何指示浏览器在获取边缘块之前稍等一会儿?

编辑II
使用shaka-player而不是dash.js可以正常运行,不会出现404错误。配置为:
player.configure(
{
streaming:
{
lowLatencyMode: true,
inaccurateManifestTolerance: 0,
rebufferingGoal: 0.1,
}
});客户端
服务器
(供参考,以下是FFmpeg生成的mpd文件)
<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:dash:schema:mpd:2011"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
profiles="urn:mpeg:dash:profile:isoff-live:2011"
type="dynamic"
minimumUpdatePeriod="PT500S"
availabilityStartTime="2021-05-24T14:50:00.263Z"
publishTime="2021-05-24T15:22:45.335Z"
timeShiftBufferDepth="PT50.0S"
maxSegmentDuration="PT2.0S"
minBufferTime="PT5.0S">
<ProgramInformation>
</ProgramInformation>
<ServiceDescription id="0">
<Latency target="3000" referenceId="0"/>
</ServiceDescription>
<Period id="0" start="PT0.0S">
<AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="24/1" maxWidth="1280" maxHeight="682" par="15:8" lang="und">
<Resync dT="200000" type="0"/>
<Representation id="0" mimeType="video/mp4" codecs="avc1.64081f" bandwidth="1000000" width="1280" height="682" sar="1023:1024">
<ProducerReferenceTime id="0" inband="true" type="captured" wallClockTime="2021-05-24T14:50:00.263Z" presentationTime="0">
<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014" value="/pelican/testPlayers/time.php"/>
</ProducerReferenceTime>
<Resync dT="5000000" type="1"/>
<SegmentTemplate timescale="1000000" duration="2000000" availabilityTimeOffset="1.800" availabilityTimeComplete="false" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
<Resync dT="200000" type="0"/>
<Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="116317" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
<ProducerReferenceTime id="1" inband="true" type="captured" wallClockTime="2021-05-24T14:50:00.306Z" presentationTime="0">
<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014" value="/pelican/testPlayers/time.php"/>
</ProducerReferenceTime>
<Resync dT="21333" type="1"/>
<SegmentTemplate timescale="1000000" duration="2000000" availabilityTimeOffset="1.800" availabilityTimeComplete="false" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014" value="/pelican/testPlayers/time.php"/>
</MPD>发布于 2021-05-25 16:33:45
输入ThreeHourMovie.mp4的帧速率为24 at (参见AdaptationSet@frameRate),因此将keyint设置为120将在x264输出时每5秒给出一个IDR。
您正在指示破折号修饰符(通过seg_duration)输出和信号2s段,但这是不可能的,因为段必须从IDR开始(如您所链接的指南中所提到的)。因此,muxer输出5s段,但是在清单中发出信号2s,这显然是不正确的。
将keyint更改为seg_duration的正确倍数(在本例中为keyint=48 ),它可能会开始工作。
发布于 2022-03-11 21:51:54
我在Exoplayer上观察到了同样的情况。但是,如果我设置值"-use_timeline 1",那么问题就不再存在了。但是,当use_timeline设置为1时,模板上不会有部分段。我不确定这是否是ffmpeg的错误。
https://stackoverflow.com/questions/67674772
复制相似问题