loadMP4File接口新增支持seek_ms与speed参数 (#4261)

This commit is contained in:
xia-chu
2025-10-18 12:36:46 +08:00
parent 676000e355
commit 6d01aa6389
2 changed files with 25 additions and 0 deletions

View File

@@ -2612,6 +2612,18 @@
"description": "是否循环点播mp4文件如果配置文件已经开启循环点播此参数无效",
"disabled": true
},
{
"key": "seek_ms",
"value": "0",
"description": "点播seek到特定位置单位毫秒",
"disabled": true
},
{
"key": "speed",
"value": "1.0",
"description": "播放速度, float类型",
"disabled": true
},
{
"key": "enable_hls",
"value": "",

View File

@@ -2251,6 +2251,19 @@ void installWebApi() {
// sample_ms设置为0从配置文件加载file_repeat可以指定如果配置文件也指定循环解复用那么强制开启 [AUTO-TRANSLATED:23e826b4]
// sample_ms is set to 0, loaded from the configuration file; file_repeat can be specified, if the configuration file also specifies loop demultiplexing, then force it to be enabled
reader->startReadMP4(0, true, allArgs["file_repeat"]);
auto seek_ms = allArgs["seek_ms"].as<uint32_t>();
auto speed = allArgs["speed"].as<float>();
if (seek_ms || speed) {
auto p = static_pointer_cast<MediaSourceEvent>(reader);
p->getOwnerPoller(MediaSource::NullMediaSource())->async([seek_ms, speed, p]() {
if (seek_ms) {
p->seekTo(MediaSource::NullMediaSource(), seek_ms);
}
if (speed && speed != 1.0) {
p->speed(MediaSource::NullMediaSource(), speed);
}
});
}
val["data"]["duration_ms"] = (Json::UInt64)reader->getDemuxer()->getDurationMS();
});
#endif