Browse Source

fix video stream selection for remote streams (#2176)

pull/2177/head
Jason Dove 4 weeks ago committed by GitHub
parent
commit
79496e688b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs
  2. 12
      ErsatzTV.Application/Troubleshooting/Commands/PrepareTroubleshootingPlaybackHandler.cs
  3. 8
      ErsatzTV.FFmpeg/OutputFormat/OutputFormatHls.cs
  4. 18
      ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs

12
ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs

@ -295,6 +295,16 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -295,6 +295,16 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
audioPath = string.Empty;
}
bool hlsRealtime = request.HlsRealtime;
if (playoutItemWithPath.PlayoutItem.MediaItem is RemoteStream remoteStream)
{
// duration implies live input which we cannot burst
if (remoteStream.Duration.HasValue)
{
hlsRealtime = true;
}
}
bool saveReports = await dbContext.ConfigElements
.GetValue<bool>(ConfigElementKey.FFmpegSaveReports)
.Map(result => result.IfNone(false));
@ -329,7 +339,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -329,7 +339,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
channel.FFmpegProfile.VaapiDriver,
channel.FFmpegProfile.VaapiDevice,
Optional(channel.FFmpegProfile.QsvExtraHardwareFrames),
request.HlsRealtime,
hlsRealtime,
playoutItemWithPath.PlayoutItem.FillerKind,
inPoint,
outPoint,

12
ErsatzTV.Application/Troubleshooting/Commands/PrepareTroubleshootingPlaybackHandler.cs

@ -93,6 +93,16 @@ public class PrepareTroubleshootingPlaybackHandler( @@ -93,6 +93,16 @@ public class PrepareTroubleshootingPlaybackHandler(
duration = TimeSpan.FromSeconds(30);
}
var hlsRealtime = false;
if (mediaItem is RemoteStream remoteStream)
{
// duration implies live input which we cannot burst
if (remoteStream.Duration.HasValue)
{
hlsRealtime = true;
}
}
Command process = await ffmpegProcessService.ForPlayoutItem(
ffmpegPath,
ffprobePath,
@ -122,7 +132,7 @@ public class PrepareTroubleshootingPlaybackHandler( @@ -122,7 +132,7 @@ public class PrepareTroubleshootingPlaybackHandler(
ffmpegProfile.VaapiDriver,
ffmpegProfile.VaapiDevice,
Option<int>.None,
false,
hlsRealtime,
FillerKind.None,
TimeSpan.Zero,
duration,

8
ErsatzTV.FFmpeg/OutputFormat/OutputFormatHls.cs

@ -58,14 +58,6 @@ public class OutputFormatHls : IPipelineStep @@ -58,14 +58,6 @@ public class OutputFormatHls : IPipelineStep
_segmentTemplate
];
if (_isTroubleshooting)
{
result.AddRange(
[
"-hls_playlist_type", "vod"
]);
}
string pdt = _isTroubleshooting ? string.Empty : "program_date_time+omit_endlist+";
if (_isFirstTranscode)

18
ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs

@ -167,7 +167,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider @@ -167,7 +167,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
"-i", filePath
];
//_logger.LogDebug("ffprobe arguments {FFProbeArguments}", arguments);
//_logger.LogDebug("ffprobe arguments {FFProbeArguments}", arguments.ToList());
BufferedCommandResult probe = await Cli.Wrap(ffprobePath)
.WithArguments(arguments)
@ -335,7 +335,10 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider @@ -335,7 +335,10 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
version.Streams.Add(stream);
}
FFprobeStreamData videoStream = json.streams?.FirstOrDefault(s => s.codec_type == "video");
FFprobeStreamData videoStream = json.streams?
.Where(s => s.codec_type == "video")
.OrderByDescending(s => ParseBitRate(s.bit_rate))
.FirstOrDefault();
if (videoStream != null)
{
version.SampleAspectRatio = string.IsNullOrWhiteSpace(videoStream.sample_aspect_ratio)
@ -494,6 +497,16 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider @@ -494,6 +497,16 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
return Task.FromResult(path);
}
private static long ParseBitRate(string bitRate)
{
if (long.TryParse(bitRate, out long result))
{
return result;
}
return 0;
}
// ReSharper disable InconsistentNaming
public record FFprobe(FFprobeFormat format, List<FFprobeStreamData> streams, List<FFprobeChapter> chapters);
@ -520,6 +533,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider @@ -520,6 +533,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
string color_primaries,
string field_order,
string r_frame_rate,
string bit_rate,
string bits_per_raw_sample,
FFprobeDisposition disposition,
FFprobeTags tags);

Loading…
Cancel
Save