mirror of https://github.com/ErsatzTV/ErsatzTV.git
33 changed files with 164 additions and 168 deletions
@ -1,3 +1,5 @@ |
|||||||
namespace ErsatzTV.Application.Channels; |
using ErsatzTV.FFmpeg; |
||||||
|
|
||||||
public record GetChannelFramerate(string ChannelNumber) : IRequest<Option<int>>; |
namespace ErsatzTV.Application.Channels; |
||||||
|
|
||||||
|
public record GetChannelFramerate(string ChannelNumber) : IRequest<Option<FrameRate>>; |
||||||
|
|||||||
@ -1,8 +1,8 @@ |
|||||||
namespace ErsatzTV.FFmpeg.Filter; |
namespace ErsatzTV.FFmpeg.Filter; |
||||||
|
|
||||||
public class ResetPtsFilter(string fps) : BaseFilter |
public class ResetPtsFilter(FrameRate frameRate) : BaseFilter |
||||||
{ |
{ |
||||||
public override string Filter => $"setpts=PTS-STARTPTS,fps={fps}"; |
public override string Filter => $"setpts=PTS-STARTPTS,fps={frameRate.RFrameRate}"; |
||||||
|
|
||||||
public override FrameState NextState(FrameState currentState) => currentState; |
public override FrameState NextState(FrameState currentState) => currentState with { FrameRate = frameRate }; |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,30 @@ |
|||||||
|
namespace ErsatzTV.FFmpeg; |
||||||
|
|
||||||
|
public record FrameRate(string? FrameRateString) |
||||||
|
{ |
||||||
|
public double ParsedFrameRate { get; init; } = ParseFrameRate(FrameRateString, 24.0); |
||||||
|
|
||||||
|
public string RFrameRate { get; init; } = FrameRateString ?? "24"; |
||||||
|
|
||||||
|
public static FrameRate DefaultFrameRate => new("24"); |
||||||
|
|
||||||
|
public static double ParseFrameRate(string? rFrameRate, double defaultFrameRate) |
||||||
|
{ |
||||||
|
double frameRate = defaultFrameRate; |
||||||
|
|
||||||
|
if (double.TryParse(rFrameRate, out double value)) |
||||||
|
{ |
||||||
|
frameRate = value; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
string[] split = (rFrameRate ?? string.Empty).Split("/"); |
||||||
|
if (int.TryParse(split[0], out int left) && int.TryParse(split[1], out int right) && right != 0) |
||||||
|
{ |
||||||
|
frameRate = left / (double)right; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return frameRate; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,24 +1,18 @@ |
|||||||
using System.Globalization; |
using ErsatzTV.FFmpeg.Environment; |
||||||
using ErsatzTV.FFmpeg.Environment; |
|
||||||
|
|
||||||
namespace ErsatzTV.FFmpeg.OutputOption; |
namespace ErsatzTV.FFmpeg.OutputOption; |
||||||
|
|
||||||
public class FrameRateOutputOption : IPipelineStep |
public class FrameRateOutputOption(FrameRate frameRate) : IPipelineStep |
||||||
{ |
{ |
||||||
private readonly int _frameRate; |
public EnvironmentVariable[] EnvironmentVariables => []; |
||||||
|
public string[] GlobalOptions => []; |
||||||
|
public string[] InputOptions(InputFile inputFile) => []; |
||||||
|
public string[] FilterOptions => []; |
||||||
|
|
||||||
public FrameRateOutputOption(int frameRate) => _frameRate = frameRate; |
public string[] OutputOptions => ["-r", frameRate.RFrameRate, "-vsync", "cfr"]; |
||||||
|
|
||||||
public EnvironmentVariable[] EnvironmentVariables => Array.Empty<EnvironmentVariable>(); |
|
||||||
public string[] GlobalOptions => Array.Empty<string>(); |
|
||||||
public string[] InputOptions(InputFile inputFile) => Array.Empty<string>(); |
|
||||||
public string[] FilterOptions => Array.Empty<string>(); |
|
||||||
|
|
||||||
public string[] OutputOptions => new[] |
|
||||||
{ "-r", _frameRate.ToString(CultureInfo.InvariantCulture), "-vsync", "cfr" }; |
|
||||||
|
|
||||||
public FrameState NextState(FrameState currentState) => currentState with |
public FrameState NextState(FrameState currentState) => currentState with |
||||||
{ |
{ |
||||||
FrameRate = _frameRate |
FrameRate = frameRate |
||||||
}; |
}; |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue