From e5ef9be09c139bf67954f1f2c24913f60a35413c Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Thu, 30 Oct 2025 14:37:16 -0500 Subject: [PATCH] fix explicit audio decoder on combined input (#2582) --- CHANGELOG.md | 1 + ErsatzTV.FFmpeg/CommandGenerator.cs | 17 ++++++++++++++++- ErsatzTV.FFmpeg/Decoder/DecoderAacLatm.cs | 4 ++-- ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1e325cc4..c8a689e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix crashes due to invalid smart collection searches, e.g. `smart_collection:"this collection does not exist"` - Fix UI crash when editing block playout that has default deco - Fix playback failure when seeking content with certain DTS audio (e.g. DTS-HD MA) +- Properly set explicit audio decoder on combined audio and video input file ## [25.8.0] - 2025-10-26 ### Added diff --git a/ErsatzTV.FFmpeg/CommandGenerator.cs b/ErsatzTV.FFmpeg/CommandGenerator.cs index 9aa2c8f54..9e2ddeac9 100644 --- a/ErsatzTV.FFmpeg/CommandGenerator.cs +++ b/ErsatzTV.FFmpeg/CommandGenerator.cs @@ -1,4 +1,5 @@ -using ErsatzTV.FFmpeg.Encoder; +using ErsatzTV.FFmpeg.Decoder; +using ErsatzTV.FFmpeg.Encoder; using ErsatzTV.FFmpeg.Environment; using ErsatzTV.FFmpeg.Filter; using ErsatzTV.FFmpeg.GlobalOption; @@ -27,6 +28,9 @@ public static class CommandGenerator arguments.AddRange(step.GlobalOptions); } + bool isSameAudioAndVideo = maybeAudioInputFile.IsSome && maybeVideoInputFile.IsSome && + maybeAudioInputFile.Map(f => f.Path) == maybeVideoInputFile.Map(f => f.Path); + var includedPaths = new System.Collections.Generic.HashSet(); foreach (VideoInputFile videoInputFile in maybeVideoInputFile) { @@ -37,6 +41,17 @@ public static class CommandGenerator arguments.AddRange(step.InputOptions(videoInputFile)); } + if (isSameAudioAndVideo) + { + foreach (AudioInputFile audioInputFile in maybeAudioInputFile) + { + foreach (IDecoder decoder in audioInputFile.InputOptions.OfType()) + { + arguments.AddRange(decoder.InputOptions(audioInputFile)); + } + } + } + arguments.AddRange(["-i", videoInputFile.Path]); } diff --git a/ErsatzTV.FFmpeg/Decoder/DecoderAacLatm.cs b/ErsatzTV.FFmpeg/Decoder/DecoderAacLatm.cs index 639cfcce4..d85e3bd08 100644 --- a/ErsatzTV.FFmpeg/Decoder/DecoderAacLatm.cs +++ b/ErsatzTV.FFmpeg/Decoder/DecoderAacLatm.cs @@ -1,10 +1,10 @@ using ErsatzTV.FFmpeg.Environment; -using ErsatzTV.FFmpeg.InputOption; namespace ErsatzTV.FFmpeg.Decoder; -public class DecoderAacLatm : IInputOption +public class DecoderAacLatm : IDecoder { + public string Name => "aac_latm"; public EnvironmentVariable[] EnvironmentVariables => []; public string[] GlobalOptions => []; public string[] FilterOptions => []; diff --git a/ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs b/ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs index 1bc18d7f1..df4066518 100644 --- a/ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs +++ b/ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs @@ -1,10 +1,10 @@ using ErsatzTV.FFmpeg.Environment; -using ErsatzTV.FFmpeg.InputOption; namespace ErsatzTV.FFmpeg.Decoder; -public class DecoderDtsCoreOnly : IInputOption +public class DecoderDtsCoreOnly : IDecoder { + public string Name => "dts"; public EnvironmentVariable[] EnvironmentVariables => []; public string[] GlobalOptions => []; public string[] FilterOptions => [];