优化直播录制逻辑; 优化已录制时长显示

This commit is contained in:
nilaoda 2023-06-28 15:22:05 +08:00
parent e55dd5ace2
commit d58168a337
4 changed files with 29 additions and 11 deletions

View File

@ -134,7 +134,7 @@ namespace N_m3u8DL_RE.Parser
try try
{ {
await semaphore.WaitAsync(); await semaphore.WaitAsync();
int retryCount = 3; //增加重试 int retryCount = 5; //增加重试
reGet: reGet:
try try
{ {
@ -145,7 +145,7 @@ namespace N_m3u8DL_RE.Parser
if (retryCount-- > 0) if (retryCount-- > 0)
{ {
Logger.WarnMarkUp($"[grey]Refresh Exception: {ex.Message.EscapeMarkup()} retryCount: {retryCount}[/]"); Logger.WarnMarkUp($"[grey]Refresh Exception: {ex.Message.EscapeMarkup()} retryCount: {retryCount}[/]");
await Task.Delay(300); await Task.Delay(1000);
goto reGet; goto reGet;
} }
else throw; else throw;

View File

@ -14,14 +14,26 @@ namespace N_m3u8DL_RE.Column
{ {
protected override bool NoWrap => true; protected override bool NoWrap => true;
private ConcurrentDictionary<int, int> _recodingDurDic; private ConcurrentDictionary<int, int> _recodingDurDic;
public Style MyStyle { get; set; } = new Style(foreground: Color.Grey); private ConcurrentDictionary<int, int>? _refreshedDurDic;
public Style GreyStyle { get; set; } = new Style(foreground: Color.Grey);
public Style MyStyle { get; set; } = new Style(foreground: Color.DarkGreen);
public RecordingDurationColumn(ConcurrentDictionary<int, int> recodingDurDic) public RecordingDurationColumn(ConcurrentDictionary<int, int> recodingDurDic)
{ {
_recodingDurDic = recodingDurDic; _recodingDurDic = recodingDurDic;
} }
public RecordingDurationColumn(ConcurrentDictionary<int, int> recodingDurDic, ConcurrentDictionary<int, int> refreshedDurDic)
{
_recodingDurDic = recodingDurDic;
_refreshedDurDic = refreshedDurDic;
}
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime) public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
{ {
return new Text(GlobalUtil.FormatTime(_recodingDurDic[task.Id]), MyStyle).LeftAligned(); if (_refreshedDurDic == null)
return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}", MyStyle).LeftAligned();
else
{
return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}/{GlobalUtil.FormatTime(_refreshedDurDic[task.Id])}", GreyStyle);
}
} }
} }
} }

View File

@ -641,7 +641,7 @@ namespace N_m3u8DL_RE.DownloadManager
} }
} }
if (STOP_FLAG) if (STOP_FLAG && source.Count == 0)
break; break;
} }
@ -720,11 +720,6 @@ namespace N_m3u8DL_RE.DownloadManager
Logger.WarnMarkUp($"[darkorange3_1]{ResString.liveLimitReached}[/]"); Logger.WarnMarkUp($"[darkorange3_1]{ResString.liveLimitReached}[/]");
STOP_FLAG = true; STOP_FLAG = true;
CancellationTokenSource.Cancel(); CancellationTokenSource.Cancel();
foreach (var target in BlockDic.Values)
{
target.Complete();
}
} }
}); });
@ -743,6 +738,11 @@ namespace N_m3u8DL_RE.DownloadManager
{ {
Logger.ErrorMarkUp(e); Logger.ErrorMarkUp(e);
STOP_FLAG = true; STOP_FLAG = true;
//停止所有Block
foreach (var target in BlockDic.Values)
{
target.Complete();
}
} }
} }
} }
@ -825,7 +825,7 @@ namespace N_m3u8DL_RE.DownloadManager
progress.Columns(new ProgressColumn[] progress.Columns(new ProgressColumn[]
{ {
new TaskDescriptionColumn() { Alignment = Justify.Left }, new TaskDescriptionColumn() { Alignment = Justify.Left },
new RecordingDurationColumn(RecordedDurDic), //时长显示 new RecordingDurationColumn(RecordedDurDic, RefreshedDurDic), //时长显示
new RecordingStatusColumn(), new RecordingStatusColumn(),
new PercentageColumn(), new PercentageColumn(),
new DownloadSpeedColumn(SpeedContainerDic), //速度计算 new DownloadSpeedColumn(SpeedContainerDic), //速度计算

View File

@ -96,6 +96,12 @@ namespace N_m3u8DL_RE
throw new ArgumentException("MuxAfterDone disabled, MuxImports not allowed!"); throw new ArgumentException("MuxAfterDone disabled, MuxImports not allowed!");
} }
if (option.LivePipeMux && !option.LiveRealTimeMerge)
{
Logger.WarnMarkUp("LivePipeMux detected, forced enable LiveRealTimeMerge");
option.LiveRealTimeMerge = true;
}
//预先检查ffmpeg //预先检查ffmpeg
if (option.FFmpegBinaryPath == null) if (option.FFmpegBinaryPath == null)
option.FFmpegBinaryPath = GlobalUtil.FindExecutable("ffmpeg"); option.FFmpegBinaryPath = GlobalUtil.FindExecutable("ffmpeg");