mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
Accelerate the ready speed of certain media that actually only have a single video track but the metadata contains an audio track (#3885)
加快某些实际上只有单视频track但是metadata包含音频track的媒体Ready速度,比如GB28181 PS流 --------- Co-authored-by: TalusL <liangzhuohua@genew.com>
This commit is contained in:
parent
7c5ba5a099
commit
e2ac6dc176
@ -121,6 +121,9 @@ mediaServerId=your_server_id
|
||||
|
||||
#最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track
|
||||
wait_track_ready_ms=10000
|
||||
#最多等待音频Track收到数据时间,单位毫秒,超时且完全没收到音频数据,忽略音频Track
|
||||
#加快某些带封装的流metadata说明有音频,但是实际上没有的流ready时间(比如很多厂商的GB28181 PS)
|
||||
wait_audio_track_data_ms=1000
|
||||
#如果流只有单Track,最多等待若干毫秒,超时后未收到其他Track的数据,则认为是单Track
|
||||
#如果协议元数据有声明特定track数,那么无此等待时间
|
||||
wait_add_track_ms=3000
|
||||
|
@ -107,6 +107,26 @@ void MediaSink::checkTrackIfReady() {
|
||||
}
|
||||
}
|
||||
|
||||
// 等待音频超时时间
|
||||
GET_CONFIG(uint32_t, kWaitAudioTrackDataMS, General::kWaitAudioTrackDataMS);
|
||||
if (_max_track_size > 1) {
|
||||
for (auto it = _track_map.begin(); it != _track_map.end(); ++it) {
|
||||
if (it->second.first->getTrackType() != TrackAudio) {
|
||||
continue;
|
||||
}
|
||||
if (_ticker.elapsedTime() > kWaitAudioTrackDataMS && !it->second.second) {
|
||||
// 音频超时且完全没收到音频数据,忽略音频
|
||||
auto index = it->second.first->getIndex();
|
||||
WarnL << "audio track " << "index " << index << " codec " << it->second.first->getCodecName() << " receive no data for long "
|
||||
<< _ticker.elapsedTime() << "ms. Ignore it!";
|
||||
it = _track_map.erase(it);
|
||||
_max_track_size -= 1;
|
||||
_track_ready_callback.erase(index);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_all_track_ready) {
|
||||
GET_CONFIG(uint32_t, kMaxWaitReadyMS, General::kWaitTrackReadyMS);
|
||||
if (_ticker.elapsedTime() > kMaxWaitReadyMS) {
|
||||
|
@ -81,6 +81,7 @@ const string kMergeWriteMS = GENERAL_FIELD "mergeWriteMS";
|
||||
const string kCheckNvidiaDev = GENERAL_FIELD "check_nvidia_dev";
|
||||
const string kEnableFFmpegLog = GENERAL_FIELD "enable_ffmpeg_log";
|
||||
const string kWaitTrackReadyMS = GENERAL_FIELD "wait_track_ready_ms";
|
||||
const string kWaitAudioTrackDataMS = GENERAL_FIELD "wait_audio_track_data_ms";
|
||||
const string kWaitAddTrackMS = GENERAL_FIELD "wait_add_track_ms";
|
||||
const string kUnreadyFrameCache = GENERAL_FIELD "unready_frame_cache";
|
||||
const string kBroadcastPlayerCountChanged = GENERAL_FIELD "broadcast_player_count_changed";
|
||||
@ -97,6 +98,7 @@ static onceToken token([]() {
|
||||
mINI::Instance()[kCheckNvidiaDev] = 1;
|
||||
mINI::Instance()[kEnableFFmpegLog] = 0;
|
||||
mINI::Instance()[kWaitTrackReadyMS] = 10000;
|
||||
mINI::Instance()[kWaitAudioTrackDataMS] = 1000;
|
||||
mINI::Instance()[kWaitAddTrackMS] = 3000;
|
||||
mINI::Instance()[kUnreadyFrameCache] = 100;
|
||||
mINI::Instance()[kBroadcastPlayerCountChanged] = 0;
|
||||
|
@ -195,6 +195,9 @@ extern const std::string kCheckNvidiaDev;
|
||||
extern const std::string kEnableFFmpegLog;
|
||||
// 最多等待未初始化的Track 10秒,超时之后会忽略未初始化的Track
|
||||
extern const std::string kWaitTrackReadyMS;
|
||||
//最多等待音频Track收到数据时间,单位毫秒,超时且完全没收到音频数据,忽略音频Track
|
||||
//加快某些带封装的流metadata说明有音频,但是实际上没有的流ready时间(比如很多厂商的GB28181 PS)
|
||||
extern const std::string kWaitAudioTrackDataMS;
|
||||
// 如果直播流只有单Track,最多等待3秒,超时后未收到其他Track的数据,则认为是单Track
|
||||
// 如果协议元数据有声明特定track数,那么无此等待时间
|
||||
extern const std::string kWaitAddTrackMS;
|
||||
|
Loading…
Reference in New Issue
Block a user