Use enums for encoding options (#12561)

This commit is contained in:
Tim Eisele
2024-09-09 16:43:37 +02:00
committed by GitHub
parent 54f663b0f3
commit 0d85af019c
20 changed files with 884 additions and 476 deletions

View File

@@ -1,3 +1,5 @@
#pragma warning disable CA1819 // XML serialization handles collections improperly, so we need to use arrays
#nullable disable
using MediaBrowser.Model.Entities;
@@ -30,9 +32,9 @@ public class EncodingOptions
EnableTonemapping = false;
EnableVppTonemapping = false;
EnableVideoToolboxTonemapping = false;
TonemappingAlgorithm = "bt2390";
TonemappingMode = "auto";
TonemappingRange = "auto";
TonemappingAlgorithm = TonemappingAlgorithm.bt2390;
TonemappingMode = TonemappingMode.auto;
TonemappingRange = TonemappingRange.auto;
TonemappingDesat = 0;
TonemappingPeak = 100;
TonemappingParam = 0;
@@ -41,7 +43,7 @@ public class EncodingOptions
H264Crf = 23;
H265Crf = 28;
DeinterlaceDoubleRate = false;
DeinterlaceMethod = "yadif";
DeinterlaceMethod = DeinterlaceMethod.yadif;
EnableDecodingColorDepth10Hevc = true;
EnableDecodingColorDepth10Vp9 = true;
// Enhanced Nvdec or system native decoder is required for DoVi to SDR tone-mapping.
@@ -53,8 +55,8 @@ public class EncodingOptions
AllowHevcEncoding = false;
AllowAv1Encoding = false;
EnableSubtitleExtraction = true;
AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = new[] { "mkv" };
HardwareDecodingCodecs = new string[] { "h264", "vc1" };
AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = ["mkv"];
HardwareDecodingCodecs = ["h264", "vc1"];
}
/// <summary>
@@ -120,7 +122,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the hardware acceleration type.
/// </summary>
public string HardwareAccelerationType { get; set; }
public HardwareAccelerationType HardwareAccelerationType { get; set; }
/// <summary>
/// Gets or sets the FFmpeg path as set by the user via the UI.
@@ -160,17 +162,17 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the tone-mapping algorithm.
/// </summary>
public string TonemappingAlgorithm { get; set; }
public TonemappingAlgorithm TonemappingAlgorithm { get; set; }
/// <summary>
/// Gets or sets the tone-mapping mode.
/// </summary>
public string TonemappingMode { get; set; }
public TonemappingMode TonemappingMode { get; set; }
/// <summary>
/// Gets or sets the tone-mapping range.
/// </summary>
public string TonemappingRange { get; set; }
public TonemappingRange TonemappingRange { get; set; }
/// <summary>
/// Gets or sets the tone-mapping desaturation.
@@ -210,7 +212,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the encoder preset.
/// </summary>
public string EncoderPreset { get; set; }
public EncoderPreset? EncoderPreset { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the framerate is doubled when deinterlacing.
@@ -220,7 +222,7 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the deinterlace method.
/// </summary>
public string DeinterlaceMethod { get; set; }
public DeinterlaceMethod DeinterlaceMethod { get; set; }
/// <summary>
/// Gets or sets a value indicating whether 10bit HEVC decoding is enabled.

View File

@@ -0,0 +1,19 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing deinterlace methods.
/// </summary>
public enum DeinterlaceMethod
{
/// <summary>
/// YADIF.
/// </summary>
yadif = 0,
/// <summary>
/// BWDIF.
/// </summary>
bwdif = 1
}

View File

@@ -0,0 +1,64 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing encoder presets.
/// </summary>
public enum EncoderPreset
{
/// <summary>
/// Auto preset.
/// </summary>
auto = 0,
/// <summary>
/// Placebo preset.
/// </summary>
placebo = 1,
/// <summary>
/// Veryslow preset.
/// </summary>
veryslow = 2,
/// <summary>
/// Slower preset.
/// </summary>
slower = 3,
/// <summary>
/// Slow preset.
/// </summary>
slow = 4,
/// <summary>
/// Medium preset.
/// </summary>
medium = 5,
/// <summary>
/// Fast preset.
/// </summary>
fast = 6,
/// <summary>
/// Faster preset.
/// </summary>
faster = 7,
/// <summary>
/// Veryfast preset.
/// </summary>
veryfast = 8,
/// <summary>
/// Superfast preset.
/// </summary>
superfast = 9,
/// <summary>
/// Ultrafast preset.
/// </summary>
ultrafast = 10
}

View File

@@ -0,0 +1,49 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing hardware acceleration types.
/// </summary>
public enum HardwareAccelerationType
{
/// <summary>
/// Software accelleration.
/// </summary>
none = 0,
/// <summary>
/// AMD AMF.
/// </summary>
amf = 1,
/// <summary>
/// Intel Quick Sync Video.
/// </summary>
qsv = 2,
/// <summary>
/// NVIDIA NVENC.
/// </summary>
nvenc = 3,
/// <summary>
/// Video4Linux2 V4L2M2M.
/// </summary>
v4l2m2m = 4,
/// <summary>
/// Video Acceleration API (VAAPI).
/// </summary>
vaapi = 5,
/// <summary>
/// Video ToolBox.
/// </summary>
videotoolbox = 6,
/// <summary>
/// Rockchip Media Process Platform (RKMPP).
/// </summary>
rkmpp = 7
}

View File

@@ -0,0 +1,49 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing tonemapping algorithms.
/// </summary>
public enum TonemappingAlgorithm
{
/// <summary>
/// None.
/// </summary>
none = 0,
/// <summary>
/// Clip.
/// </summary>
clip = 1,
/// <summary>
/// Linear.
/// </summary>
linear = 2,
/// <summary>
/// Gamma.
/// </summary>
gamma = 3,
/// <summary>
/// Reinhard.
/// </summary>
reinhard = 4,
/// <summary>
/// Hable.
/// </summary>
hable = 5,
/// <summary>
/// Mobius.
/// </summary>
mobius = 6,
/// <summary>
/// BT2390.
/// </summary>
bt2390 = 7
}

View File

@@ -0,0 +1,34 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing tonemapping modes.
/// </summary>
public enum TonemappingMode
{
/// <summary>
/// Auto.
/// </summary>
auto = 0,
/// <summary>
/// Max.
/// </summary>
max = 1,
/// <summary>
/// RGB.
/// </summary>
rgb = 2,
/// <summary>
/// Lum.
/// </summary>
lum = 3,
/// <summary>
/// ITP.
/// </summary>
itp = 4
}

View File

@@ -0,0 +1,24 @@
#pragma warning disable SA1300 // Lowercase required for backwards compat.
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Enum containing tonemapping ranges.
/// </summary>
public enum TonemappingRange
{
/// <summary>
/// Auto.
/// </summary>
auto = 0,
/// <summary>
/// TV.
/// </summary>
tv = 1,
/// <summary>
/// PC.
/// </summary>
pc = 2
}

View File

@@ -1,43 +0,0 @@
namespace MediaBrowser.Model.Session
{
/// <summary>
/// Enum HardwareEncodingType.
/// </summary>
public enum HardwareEncodingType
{
/// <summary>
/// AMD AMF.
/// </summary>
AMF = 0,
/// <summary>
/// Intel Quick Sync Video.
/// </summary>
QSV = 1,
/// <summary>
/// NVIDIA NVENC.
/// </summary>
NVENC = 2,
/// <summary>
/// Video4Linux2 V4L2.
/// </summary>
V4L2M2M = 3,
/// <summary>
/// Video Acceleration API (VAAPI).
/// </summary>
VAAPI = 4,
/// <summary>
/// Video ToolBox.
/// </summary>
VideoToolBox = 5,
/// <summary>
/// Rockchip Media Process Platform (RKMPP).
/// </summary>
RKMPP = 6
}
}

View File

@@ -1,34 +1,76 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Session
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Session;
/// <summary>
/// Class holding information on a runnning transcode.
/// </summary>
public class TranscodingInfo
{
public class TranscodingInfo
{
public string AudioCodec { get; set; }
/// <summary>
/// Gets or sets the thread count used for encoding.
/// </summary>
public string AudioCodec { get; set; }
public string VideoCodec { get; set; }
/// <summary>
/// Gets or sets the thread count used for encoding.
/// </summary>
public string VideoCodec { get; set; }
public string Container { get; set; }
/// <summary>
/// Gets or sets the thread count used for encoding.
/// </summary>
public string Container { get; set; }
public bool IsVideoDirect { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the video is passed through.
/// </summary>
public bool IsVideoDirect { get; set; }
public bool IsAudioDirect { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the audio is passed through.
/// </summary>
public bool IsAudioDirect { get; set; }
public int? Bitrate { get; set; }
/// <summary>
/// Gets or sets the bitrate.
/// </summary>
public int? Bitrate { get; set; }
public float? Framerate { get; set; }
/// <summary>
/// Gets or sets the framerate.
/// </summary>
public float? Framerate { get; set; }
public double? CompletionPercentage { get; set; }
/// <summary>
/// Gets or sets the completion percentage.
/// </summary>
public double? CompletionPercentage { get; set; }
public int? Width { get; set; }
/// <summary>
/// Gets or sets the video width.
/// </summary>
public int? Width { get; set; }
public int? Height { get; set; }
/// <summary>
/// Gets or sets the video height.
/// </summary>
public int? Height { get; set; }
public int? AudioChannels { get; set; }
/// <summary>
/// Gets or sets the audio channels.
/// </summary>
public int? AudioChannels { get; set; }
public HardwareEncodingType? HardwareAccelerationType { get; set; }
/// <summary>
/// Gets or sets the hardware acceleration type.
/// </summary>
public HardwareAccelerationType? HardwareAccelerationType { get; set; }
public TranscodeReason TranscodeReasons { get; set; }
}
/// <summary>
/// Gets or sets the transcode reasons.
/// </summary>
public TranscodeReason TranscodeReasons { get; set; }
}