From b0333e89cdd532ea01b679c0dddc861dbdd38f93 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Wed, 3 May 2023 12:08:14 -0500 Subject: [PATCH] fix fallback filler (#1265) --- CHANGELOG.md | 3 +++ .../FFmpeg/FFmpegLibraryProcessService.cs | 9 ++++++--- .../Option/InfiniteLoopInputOption.cs | 2 +- .../Pipeline/PipelineBuilderBase.cs | 18 +++++++++++------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 887624c93..74856db71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Fixed - Fix extracting embedded text subtitles that had been incompletely extracted in the past +- Fix fallback filler looping by forcing software mode for this content + - Other content will still use hardware acceleration as configured + - Hardware-accelerated fallback filler may be re-enabled in the future ## [0.7.8-beta] - 2023-04-29 ### Added diff --git a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs index 8675df3bf..764461183 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs @@ -225,7 +225,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService string videoFormat = GetVideoFormat(playbackSettings); - HardwareAccelerationMode hwAccel = GetHardwareAccelerationMode(playbackSettings); + HardwareAccelerationMode hwAccel = GetHardwareAccelerationMode(playbackSettings, fillerKind); OutputFormatKind outputFormat = channel.StreamingMode == StreamingMode.HttpLiveStreamingSegmenter ? OutputFormatKind.Hls @@ -386,7 +386,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService var videoInputFile = new VideoInputFile(videoPath, new List { ffmpegVideoStream }); - HardwareAccelerationMode hwAccel = GetHardwareAccelerationMode(playbackSettings); + HardwareAccelerationMode hwAccel = GetHardwareAccelerationMode(playbackSettings, FillerKind.None); var ffmpegState = new FFmpegState( false, @@ -716,9 +716,12 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService _ => throw new ArgumentOutOfRangeException($"unexpected video format {playbackSettings.VideoFormat}") }; - private static HardwareAccelerationMode GetHardwareAccelerationMode(FFmpegPlaybackSettings playbackSettings) => + private static HardwareAccelerationMode GetHardwareAccelerationMode( + FFmpegPlaybackSettings playbackSettings, + FillerKind fillerKind) => playbackSettings.HardwareAcceleration switch { + _ when fillerKind == FillerKind.Fallback => HardwareAccelerationMode.None, HardwareAccelerationKind.Nvenc => HardwareAccelerationMode.Nvenc, HardwareAccelerationKind.Qsv => HardwareAccelerationMode.Qsv, HardwareAccelerationKind.Vaapi => HardwareAccelerationMode.Vaapi, diff --git a/ErsatzTV.FFmpeg/Option/InfiniteLoopInputOption.cs b/ErsatzTV.FFmpeg/Option/InfiniteLoopInputOption.cs index 5c8030957..24d1ef9fa 100644 --- a/ErsatzTV.FFmpeg/Option/InfiniteLoopInputOption.cs +++ b/ErsatzTV.FFmpeg/Option/InfiniteLoopInputOption.cs @@ -32,7 +32,7 @@ public class InfiniteLoopInputOption : IInputOption : Array.Empty(); public FrameState NextState(FrameState currentState) => currentState with { Realtime = true }; - public bool AppliesTo(AudioInputFile audioInputFile) => false; + public bool AppliesTo(AudioInputFile audioInputFile) => true; public bool AppliesTo(VideoInputFile videoInputFile) => true; public bool AppliesTo(ConcatInputFile concatInputFile) => true; } diff --git a/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs b/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs index d2171c529..135261c61 100644 --- a/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs +++ b/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs @@ -539,15 +539,19 @@ public abstract class PipelineBuilderBase : IPipelineBuilder FFmpegState ffmpegState, FrameState desiredState) { - if (desiredState.InfiniteLoop) + if (!desiredState.InfiniteLoop) { - _audioInputFile.Iter( - a => a.AddOption(new InfiniteLoopInputOption(ffmpegState.EncoderHardwareAccelerationMode))); + return; + } - if (!videoStream.StillImage) - { - videoInputFile.AddOption(new InfiniteLoopInputOption(ffmpegState.EncoderHardwareAccelerationMode)); - } + foreach (AudioInputFile audioInputFile in _audioInputFile) + { + audioInputFile.AddOption(new InfiniteLoopInputOption(ffmpegState.EncoderHardwareAccelerationMode)); + } + + if (!videoStream.StillImage) + { + videoInputFile.AddOption(new InfiniteLoopInputOption(ffmpegState.EncoderHardwareAccelerationMode)); } }