fix: improve recovery and auto-start flows
This commit is contained in:
@@ -80,7 +80,9 @@ public sealed partial class FfmpegService
|
||||
var stderrLines = new Queue<string>();
|
||||
var progressSync = new object();
|
||||
double? processedSeconds = null;
|
||||
var lastReportedWholePercent = -1;
|
||||
double? lastReportedProgressPercent = null;
|
||||
string? lastReportedStage = null;
|
||||
string? lastReportedDetail = null;
|
||||
var attemptStartedAt = DateTimeOffset.UtcNow;
|
||||
var activeStage = "Finalizing MP4";
|
||||
var maxDuration = TimeSpan.FromMinutes(Math.Clamp(mp4FinalizeTimeoutMinutes, 1, 1440));
|
||||
@@ -114,19 +116,28 @@ public sealed partial class FfmpegService
|
||||
detail = $"Processed {processedSeconds.Value:F1}s";
|
||||
}
|
||||
|
||||
var wholePercent = progressPercent.HasValue ? (int)Math.Floor(progressPercent.Value) : -1;
|
||||
if (stageOverride is null && wholePercent == lastReportedWholePercent)
|
||||
var effectiveStage = stageOverride ?? activeStage;
|
||||
var normalizedProgressPercent = progressPercent.HasValue
|
||||
? Math.Round(progressPercent.Value, 1, MidpointRounding.AwayFromZero)
|
||||
: (double?)null;
|
||||
var effectiveDetail = detail ?? $"Optimizing MP4 index for {Path.GetFileName(targetPath)}";
|
||||
|
||||
if (string.Equals(effectiveStage, lastReportedStage, StringComparison.Ordinal) &&
|
||||
string.Equals(effectiveDetail, lastReportedDetail, StringComparison.Ordinal) &&
|
||||
Nullable.Equals(normalizedProgressPercent, lastReportedProgressPercent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lastReportedWholePercent = wholePercent;
|
||||
lastReportedStage = effectiveStage;
|
||||
lastReportedDetail = effectiveDetail;
|
||||
lastReportedProgressPercent = normalizedProgressPercent;
|
||||
SetPostProcessState(
|
||||
recordSessionId,
|
||||
recordTaskId,
|
||||
stageOverride ?? activeStage,
|
||||
progressPercent,
|
||||
detail ?? $"Optimizing MP4 index for {Path.GetFileName(targetPath)}");
|
||||
effectiveStage,
|
||||
normalizedProgressPercent,
|
||||
effectiveDetail);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +170,9 @@ public sealed partial class FfmpegService
|
||||
ClearErrorDetail();
|
||||
activeStage = stage;
|
||||
processedSeconds = null;
|
||||
lastReportedWholePercent = -1;
|
||||
lastReportedProgressPercent = null;
|
||||
lastReportedStage = null;
|
||||
lastReportedDetail = null;
|
||||
attemptStartedAt = DateTimeOffset.UtcNow;
|
||||
System.Threading.Interlocked.Exchange(ref lastActivityTicks, attemptStartedAt.UtcTicks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user