mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* refactor parsing ffmpeg progress/speed * log warnings when transcoding speed is potentially insufficient * dont log progress on hls direct; fix testspull/2810/head
13 changed files with 106 additions and 35 deletions
@ -0,0 +1,55 @@ |
|||||||
|
using System.Text.RegularExpressions; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
|
||||||
|
namespace ErsatzTV.Core.FFmpeg; |
||||||
|
|
||||||
|
public partial class FFmpegProgress |
||||||
|
{ |
||||||
|
public Option<double> Speed { get; private set; } = Option<double>.None; |
||||||
|
|
||||||
|
public void ParseLine(string line) |
||||||
|
{ |
||||||
|
Match match = FFmpegSpeed().Match(line); |
||||||
|
if (match.Success && double.TryParse(match.Groups[1].Value, out double speed)) |
||||||
|
{ |
||||||
|
Speed = speed; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void LogSpeed(Option<int> mediaItemId, bool isWorkingAhead, string channelNumber, ILogger logger) |
||||||
|
{ |
||||||
|
foreach (double speed in Speed) |
||||||
|
{ |
||||||
|
if (isWorkingAhead) |
||||||
|
{ |
||||||
|
if (speed < 1.0) |
||||||
|
{ |
||||||
|
logger.LogCritical( |
||||||
|
"Media item {MediaItemId} on channel {Channel} transcoded at {Speed}x (NOT throttled) which is NOT fast enough to support playback", |
||||||
|
mediaItemId, |
||||||
|
channelNumber, |
||||||
|
speed); |
||||||
|
} |
||||||
|
else if (speed <= 1.5) |
||||||
|
{ |
||||||
|
logger.LogWarning( |
||||||
|
"Media item {MediaItemId} on channel {Channel} transcoded at {Speed}x (NOT throttled) which may not be fast enough to support playback", |
||||||
|
mediaItemId, |
||||||
|
channelNumber, |
||||||
|
speed); |
||||||
|
} |
||||||
|
} |
||||||
|
else if (speed < 1.0) |
||||||
|
{ |
||||||
|
logger.LogWarning( |
||||||
|
"Media item {MediaItemId} on channel {Channel} transcoded at {Speed}x (throttled) which may not be fast enough to support playback", |
||||||
|
mediaItemId, |
||||||
|
channelNumber, |
||||||
|
speed); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[GeneratedRegex(@"speed=\s*([\d\.]+)x", RegexOptions.IgnoreCase)]
|
||||||
|
private static partial Regex FFmpegSpeed(); |
||||||
|
} |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
namespace ErsatzTV.FFmpeg.GlobalOption; |
||||||
|
|
||||||
|
public class ProgressOption : GlobalOption |
||||||
|
{ |
||||||
|
public override string[] GlobalOptions => ["-progress", "-"]; |
||||||
|
} |
||||||
Loading…
Reference in new issue