Browse Source

fix seeking content with dts audio (#2581)

* fix seeking content with dts audio

* formatting
pull/2582/head
Jason Dove 7 months ago committed by GitHub
parent
commit
e9338b534b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 24
      ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs
  3. 1
      ErsatzTV.FFmpeg/Format/AudioFormat.cs
  4. 9
      ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs

1
CHANGELOG.md

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This caused playout build errors like "Unable to locate history for playout item"
- 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)
## [25.8.0] - 2025-10-26
### Added

24
ErsatzTV.FFmpeg/Decoder/DecoderDtsCoreOnly.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
using ErsatzTV.FFmpeg.Environment;
using ErsatzTV.FFmpeg.InputOption;
namespace ErsatzTV.FFmpeg.Decoder;
public class DecoderDtsCoreOnly : IInputOption
{
public EnvironmentVariable[] EnvironmentVariables => [];
public string[] GlobalOptions => [];
public string[] FilterOptions => [];
public string[] OutputOptions => [];
public string[] InputOptions(InputFile inputFile) => ["-c:a", "dts", "-core_only", "true"];
public FrameState NextState(FrameState currentState) => currentState;
public bool AppliesTo(AudioInputFile audioInputFile) => true;
public bool AppliesTo(VideoInputFile videoInputFile) => false;
public bool AppliesTo(ConcatInputFile concatInputFile) => false;
public bool AppliesTo(GraphicsEngineInput graphicsEngineInput) => false;
}

1
ErsatzTV.FFmpeg/Format/AudioFormat.cs

@ -5,6 +5,7 @@ public static class AudioFormat @@ -5,6 +5,7 @@ public static class AudioFormat
public const string Aac = "aac";
public const string Ac3 = "ac3";
public const string AacLatm = "aac-latm";
public const string Dts = "dts";
public const string Copy = "copy";
}

9
ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs

@ -454,6 +454,15 @@ public abstract class PipelineBuilderBase : IPipelineBuilder @@ -454,6 +454,15 @@ public abstract class PipelineBuilderBase : IPipelineBuilder
AudioInputFile audioInputFile,
List<IPipelineStep> pipelineSteps)
{
// workaround for seeking with dts; certain seeks will change format when decoding (e.g. s16p to s32p)
foreach (TimeSpan _ in ffmpegState.Start.Filter(s => s > TimeSpan.Zero))
{
if (audioInputFile.Streams.OfType<AudioStream>().Any(s => s.Codec == AudioFormat.Dts))
{
audioInputFile.AddOption(new DecoderDtsCoreOnly());
}
}
// always need to specify audio codec so ffmpeg doesn't default to a codec we don't want
foreach (IEncoder step in AvailableEncoders.ForAudioFormat(ffmpegState, audioInputFile.DesiredState, _logger))
{

Loading…
Cancel
Save