Browse Source

explicitly copy all audio streams with hls direct (#933)

* ensure audio streams are always copied with hls direct

* update changelog
pull/934/head
Jason Dove 4 years ago committed by GitHub
parent
commit
7aff65f07b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 63
      ErsatzTV.FFmpeg.Tests/PipelineBuilderTests.cs
  3. 10
      ErsatzTV.FFmpeg/PipelineBuilder.cs
  4. 13
      ErsatzTV.FFmpeg/State/AudioState.cs

3
CHANGELOG.md

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Fixed
- When all audio streams are selected with `HLS Direct`, explicitly copy them without transcoding
- This only happens when the channel does not have a `Preferred Audio Language`
## [0.6.6-beta] - 2022-08-17 ## [0.6.6-beta] - 2022-08-17
### Fixed ### Fixed

63
ErsatzTV.FFmpeg.Tests/PipelineBuilderTests.cs

@ -251,6 +251,69 @@ public class PipelineGeneratorTests
"-nostdin -hide_banner -nostats -loglevel error -fflags +genpts+discardcorrupt+igndts -i /tmp/whatever.mkv -map 0:1 -map 0:0 -muxdelay 0 -muxpreload 0 -movflags +faststart -flags cgop -sc_threshold 0 -c:v copy -c:a copy -f mpegts -mpegts_flags +initial_discontinuity pipe:1"); "-nostdin -hide_banner -nostats -loglevel error -fflags +genpts+discardcorrupt+igndts -i /tmp/whatever.mkv -map 0:1 -map 0:0 -muxdelay 0 -muxpreload 0 -movflags +faststart -flags cgop -sc_threshold 0 -c:v copy -c:a copy -f mpegts -mpegts_flags +initial_discontinuity pipe:1");
} }
[Test]
public void HlsDirect_Test_All_Audio_Streams()
{
var videoInputFile = new VideoInputFile(
"/tmp/whatever.mkv",
new List<VideoStream>
{ new(0, VideoFormat.H264, new PixelFormatYuv420P(), new FrameSize(1920, 1080), "16:9", "24", false) });
Option<AudioInputFile> audioInputFile = Option<AudioInputFile>.None;
var desiredState = new FrameState(
true,
false,
VideoFormat.Copy,
new PixelFormatYuv420P(),
new FrameSize(1920, 1080),
new FrameSize(1920, 1080),
"16:9",
Option<int>.None,
2000,
4000,
90_000,
false);
var ffmpegState = new FFmpegState(
false,
HardwareAccelerationMode.None,
HardwareAccelerationMode.None,
Option<string>.None,
Option<string>.None,
Option<TimeSpan>.None,
Option<TimeSpan>.None,
false,
Option<string>.None,
Option<string>.None,
Option<string>.None,
OutputFormatKind.MpegTs,
Option<string>.None,
Option<string>.None,
0,
Option<int>.None);
var builder = new PipelineBuilder(
new DefaultHardwareCapabilities(),
videoInputFile,
audioInputFile,
None,
None,
"",
"",
_logger);
FFmpegPipeline result = builder.Build(ffmpegState, desiredState);
result.PipelineSteps.Should().HaveCountGreaterThan(0);
result.PipelineSteps.Should().Contain(ps => ps is EncoderCopyVideo);
result.PipelineSteps.Should().Contain(ps => ps is EncoderCopyAudio);
string command = PrintCommand(videoInputFile, audioInputFile, None, None, result);
command.Should().Be(
"-nostdin -hide_banner -nostats -loglevel error -fflags +genpts+discardcorrupt+igndts -i /tmp/whatever.mkv -map 0:a -map 0:0 -muxdelay 0 -muxpreload 0 -movflags +faststart -flags cgop -sc_threshold 0 -c:v copy -c:a copy -f mpegts -mpegts_flags +initial_discontinuity pipe:1");
}
[Test] [Test]
public void Resize_Image_Test() public void Resize_Image_Test()
{ {

10
ErsatzTV.FFmpeg/PipelineBuilder.cs

@ -539,6 +539,16 @@ public class PipelineBuilder
// TODO: if all video filters are software, use software pixel format for hwaccel output // TODO: if all video filters are software, use software pixel format for hwaccel output
// might be able to skip scale_cuda=format=whatever,hwdownload,format=whatever // might be able to skip scale_cuda=format=whatever,hwdownload,format=whatever
if (_audioInputFile.IsNone)
{
// always need to specify audio codec so ffmpeg doesn't default to a codec we don't want
foreach (IEncoder step in AvailableEncoders.ForAudioFormat(AudioState.Copy, _logger))
{
currentState = step.NextState(currentState);
_pipelineSteps.Add(step);
}
}
foreach (AudioInputFile audioInputFile in _audioInputFile) foreach (AudioInputFile audioInputFile in _audioInputFile)
{ {
// always need to specify audio codec so ffmpeg doesn't default to a codec we don't want // always need to specify audio codec so ffmpeg doesn't default to a codec we don't want

13
ErsatzTV.FFmpeg/State/AudioState.cs

@ -7,4 +7,15 @@ public record AudioState(
Option<int> AudioBufferSize, Option<int> AudioBufferSize,
Option<int> AudioSampleRate, Option<int> AudioSampleRate,
Option<TimeSpan> AudioDuration, Option<TimeSpan> AudioDuration,
bool NormalizeLoudness); bool NormalizeLoudness)
{
public static readonly AudioState Copy = new(
Format.AudioFormat.Copy,
Option<int>.None,
Option<int>.None,
Option<int>.None,
Option<int>.None,
Option<TimeSpan>.None,
false
);
}

Loading…
Cancel
Save