using ErsatzTV.FFmpeg.OutputFormat; namespace ErsatzTV.FFmpeg; public record FFmpegState( bool SaveReport, HardwareAccelerationMode DecoderHardwareAccelerationMode, HardwareAccelerationMode EncoderHardwareAccelerationMode, Option VaapiDriver, Option VaapiDevice, Option Start, Option Finish, bool DoNotMapMetadata, Option MetadataServiceProvider, Option MetadataServiceName, Option MetadataAudioLanguage, Option MetadataSubtitleLanguage, Option MetadataSubtitleTitle, OutputFormatKind OutputFormat, Option HlsPlaylistPath, Option HlsSegmentTemplate, Option HlsInitTemplate, Option HlsSegmentOptions, TimeSpan PtsOffset, Option ThreadCount, Option MaybeQsvExtraHardwareFrames, bool IsSongWithProgress, bool IsHdrTonemap, string TonemapAlgorithm, bool IsTroubleshooting, bool QsvPreferNativeDecoder = false) { // the QSV upload pool needs headroom for the frames in flight through the filter graph. // extra_hw_frames=0 leaves none, so any input that is not throttled exhausts it: the graph // fails with -12 (Cannot allocate memory), h264_qsv reports "Could not open encoder before // EOF", and the output file gets no packets at all. Input throttling was the only thing // hiding it — a work-ahead start (no -readrate) and #350's cold-start burst both remove that // throttle, so the channel simply dies. A stored 0 is therefore treated as "no pool // configured" rather than honored literally (ersatztv#529) public const int MinimumQsvExtraHardwareFrames = 64; public int QsvExtraHardwareFrames => Math.Max(MaybeQsvExtraHardwareFrames.IfNone(MinimumQsvExtraHardwareFrames), MinimumQsvExtraHardwareFrames); public static FFmpegState Concat(bool saveReport, string channelName) => new( saveReport, HardwareAccelerationMode.None, HardwareAccelerationMode.None, Option.None, Option.None, Option.None, Option.None, true, // do not map metadata "ErsatzTV", channelName, Option.None, Option.None, Option.None, OutputFormatKind.MpegTs, Option.None, Option.None, Option.None, Option.None, TimeSpan.Zero, Option.None, Option.None, false, false, "linear", false); }