|
|
|
@ -10,6 +10,7 @@ using ErsatzTV.FFmpeg.Option.HardwareAcceleration; |
|
|
|
using ErsatzTV.FFmpeg.Option.Metadata; |
|
|
|
using ErsatzTV.FFmpeg.Option.Metadata; |
|
|
|
using ErsatzTV.FFmpeg.OutputFormat; |
|
|
|
using ErsatzTV.FFmpeg.OutputFormat; |
|
|
|
using ErsatzTV.FFmpeg.Protocol; |
|
|
|
using ErsatzTV.FFmpeg.Protocol; |
|
|
|
|
|
|
|
using ErsatzTV.FFmpeg.Runtime; |
|
|
|
using ErsatzTV.FFmpeg.State; |
|
|
|
using ErsatzTV.FFmpeg.State; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
|
|
|
|
@ -19,6 +20,7 @@ public class PipelineBuilder |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly Option<AudioInputFile> _audioInputFile; |
|
|
|
private readonly Option<AudioInputFile> _audioInputFile; |
|
|
|
private readonly string _fontsFolder; |
|
|
|
private readonly string _fontsFolder; |
|
|
|
|
|
|
|
private readonly IRuntimeInfo _runtimeInfo; |
|
|
|
private readonly IHardwareCapabilities _hardwareCapabilities; |
|
|
|
private readonly IHardwareCapabilities _hardwareCapabilities; |
|
|
|
private readonly ILogger _logger; |
|
|
|
private readonly ILogger _logger; |
|
|
|
private readonly List<IPipelineStep> _pipelineSteps; |
|
|
|
private readonly List<IPipelineStep> _pipelineSteps; |
|
|
|
@ -28,6 +30,7 @@ public class PipelineBuilder |
|
|
|
private readonly Option<WatermarkInputFile> _watermarkInputFile; |
|
|
|
private readonly Option<WatermarkInputFile> _watermarkInputFile; |
|
|
|
|
|
|
|
|
|
|
|
public PipelineBuilder( |
|
|
|
public PipelineBuilder( |
|
|
|
|
|
|
|
IRuntimeInfo runtimeInfo, |
|
|
|
IHardwareCapabilities hardwareCapabilities, |
|
|
|
IHardwareCapabilities hardwareCapabilities, |
|
|
|
Option<VideoInputFile> videoInputFile, |
|
|
|
Option<VideoInputFile> videoInputFile, |
|
|
|
Option<AudioInputFile> audioInputFile, |
|
|
|
Option<AudioInputFile> audioInputFile, |
|
|
|
@ -49,6 +52,7 @@ public class PipelineBuilder |
|
|
|
new ClosedGopOutputOption() |
|
|
|
new ClosedGopOutputOption() |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_runtimeInfo = runtimeInfo; |
|
|
|
_hardwareCapabilities = hardwareCapabilities; |
|
|
|
_hardwareCapabilities = hardwareCapabilities; |
|
|
|
_videoInputFile = videoInputFile; |
|
|
|
_videoInputFile = videoInputFile; |
|
|
|
_audioInputFile = audioInputFile; |
|
|
|
_audioInputFile = audioInputFile; |
|
|
|
@ -392,6 +396,7 @@ public class PipelineBuilder |
|
|
|
else if (currentState.ScaledSize != desiredState.ScaledSize) |
|
|
|
else if (currentState.ScaledSize != desiredState.ScaledSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
|
|
|
|
_runtimeInfo, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
desiredState.ScaledSize, |
|
|
|
desiredState.ScaledSize, |
|
|
|
@ -406,8 +411,9 @@ public class PipelineBuilder |
|
|
|
currentState = padStep.NextState(currentState); |
|
|
|
currentState = padStep.NextState(currentState); |
|
|
|
_videoInputFile.Iter(f => f.FilterSteps.Add(padStep)); |
|
|
|
_videoInputFile.Iter(f => f.FilterSteps.Add(padStep)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (videoStream.DisplayAspectRatio == desiredState.DisplayAspectRatio) |
|
|
|
if (videoStream.DisplayAspectRatio == desiredState.DisplayAspectRatio || |
|
|
|
|
|
|
|
ffmpegState.EncoderHardwareAccelerationMode == HardwareAccelerationMode.Qsv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IPipelineFilterStep darStep = new SetDarFilter(desiredState.DisplayAspectRatio); |
|
|
|
IPipelineFilterStep darStep = new SetDarFilter(desiredState.DisplayAspectRatio); |
|
|
|
currentState = darStep.NextState(currentState); |
|
|
|
currentState = darStep.NextState(currentState); |
|
|
|
@ -417,6 +423,7 @@ public class PipelineBuilder |
|
|
|
else if (currentState.PaddedSize != desiredState.PaddedSize) |
|
|
|
else if (currentState.PaddedSize != desiredState.PaddedSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
|
|
|
|
_runtimeInfo, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
desiredState.ScaledSize, |
|
|
|
desiredState.ScaledSize, |
|
|
|
@ -430,8 +437,9 @@ public class PipelineBuilder |
|
|
|
currentState = padStep.NextState(currentState); |
|
|
|
currentState = padStep.NextState(currentState); |
|
|
|
_videoInputFile.Iter(f => f.FilterSteps.Add(padStep)); |
|
|
|
_videoInputFile.Iter(f => f.FilterSteps.Add(padStep)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (videoStream.DisplayAspectRatio == desiredState.DisplayAspectRatio) |
|
|
|
if (videoStream.DisplayAspectRatio == desiredState.DisplayAspectRatio || |
|
|
|
|
|
|
|
ffmpegState.EncoderHardwareAccelerationMode == HardwareAccelerationMode.Qsv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IPipelineFilterStep darStep = new SetDarFilter(desiredState.DisplayAspectRatio); |
|
|
|
IPipelineFilterStep darStep = new SetDarFilter(desiredState.DisplayAspectRatio); |
|
|
|
currentState = darStep.NextState(currentState); |
|
|
|
currentState = darStep.NextState(currentState); |
|
|
|
@ -470,6 +478,7 @@ public class PipelineBuilder |
|
|
|
currentState = currentState with { PixelFormat = desiredState.PixelFormat }; |
|
|
|
currentState = currentState with { PixelFormat = desiredState.PixelFormat }; |
|
|
|
|
|
|
|
|
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
|
|
|
|
_runtimeInfo, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
desiredState.ScaledSize, |
|
|
|
desiredState.ScaledSize, |
|
|
|
@ -499,6 +508,7 @@ public class PipelineBuilder |
|
|
|
currentState = currentState with { PixelFormat = desiredState.PixelFormat }; |
|
|
|
currentState = currentState with { PixelFormat = desiredState.PixelFormat }; |
|
|
|
|
|
|
|
|
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
|
|
|
|
_runtimeInfo, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
desiredState.ScaledSize, |
|
|
|
desiredState.ScaledSize, |
|
|
|
@ -625,6 +635,7 @@ public class PipelineBuilder |
|
|
|
_videoInputFile.Map(f => f.FilterSteps.Count).IfNone(1) == 0) |
|
|
|
_videoInputFile.Map(f => f.FilterSteps.Count).IfNone(1) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
IPipelineFilterStep scaleFilter = AvailableScaleFilters.ForAcceleration( |
|
|
|
|
|
|
|
_runtimeInfo, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
ffmpegState.EncoderHardwareAccelerationMode, |
|
|
|
currentState, |
|
|
|
currentState, |
|
|
|
desiredState.ScaledSize, |
|
|
|
desiredState.ScaledSize, |
|
|
|
|