fix(flv): relax timestamp jump detection threshold

This commit is contained in:
genteure 2023-10-05 15:15:10 +08:00
parent 8e7b0946c3
commit d2440d1199
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ namespace BililiveRecorder.Flv.Pipeline.Rules
{ {
private const string TS_STORE_KEY = "Timestamp_Store_Key"; private const string TS_STORE_KEY = "Timestamp_Store_Key";
private const int JUMP_THRESHOLD = 50; private const int JUMP_THRESHOLD = 500;
private const int AUDIO_DURATION_FALLBACK = 22; private const int AUDIO_DURATION_FALLBACK = 22;
private const int AUDIO_DURATION_MIN = 20; private const int AUDIO_DURATION_MIN = 20;
@ -40,7 +40,7 @@ namespace BililiveRecorder.Flv.Pipeline.Rules
var tags = dataAction.Tags; var tags = dataAction.Tags;
var currentTimestamp = tags[0].Timestamp; var currentTimestamp = tags[0].Timestamp;
bool isFirstChunk = ts.FirstChunk; var isFirstChunk = ts.FirstChunk;
if (isFirstChunk) if (isFirstChunk)
{ {
// 第一段数据使用最小的时间戳作为基础偏移量 // 第一段数据使用最小的时间戳作为基础偏移量
@ -75,7 +75,7 @@ namespace BililiveRecorder.Flv.Pipeline.Rules
{ {
var tag = endAction.Tag; var tag = endAction.Tag;
var diff = tag.Timestamp - ts.LastOriginal; var diff = tag.Timestamp - ts.LastOriginal;
if (diff < 0 || diff > JUMP_THRESHOLD) if (diff is < 0 or > JUMP_THRESHOLD)
{ {
tag.Timestamp = ts.NextTimestampTarget; tag.Timestamp = ts.NextTimestampTarget;
} }

View File

@ -58,7 +58,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests
var originalTags = SampleFileLoader.LoadXmlFlv(path).Tags; var originalTags = SampleFileLoader.LoadXmlFlv(path).Tags;
var random = new System.Random(); var random = new System.Random();
var offset = random.Next(51, 9999); var offset = random.Next(501, 9999);
if (random.Next(2) == 1) if (random.Next(2) == 1)
offset = -offset; offset = -offset;