mirror of https://github.com/n00mkrad/flowframes
Fix lossless option being available with encoders that don't support it
This commit is contained in:
parent
a04df766fb
commit
da8a431545
|
@ -10,7 +10,7 @@ namespace Flowframes.Data
|
|||
public class EncoderInfoVideo : EncoderInfo
|
||||
{
|
||||
public Codec Codec { get; set; } = (Codec)(-1);
|
||||
public bool Lossless { get; set; } = false;
|
||||
public bool? Lossless { get; set; } = false; // True = Lossless Codec; False = Lossy codec with lossless option; null: Lossy with no lossless option
|
||||
public bool HwAccelerated { get; set; } = false;
|
||||
public int Modulo { get; set; } = 2;
|
||||
public int MaxFramerate { get; set; } = 1000;
|
||||
|
|
|
@ -305,13 +305,13 @@ namespace Flowframes
|
|||
|
||||
var entriesToAdd = Enum.GetValues(typeof(TEnum)).Cast<TEnum>().Except(exclusionList);
|
||||
var strings = entriesToAdd.Select(x => stringMap.Get(x.ToString(), true));
|
||||
comboBox.FillFromEnum(strings, stringMap, defaultIndex);
|
||||
comboBox.FillFromStrings(strings, stringMap, defaultIndex);
|
||||
}
|
||||
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, IEnumerable<TEnum> entries, Dictionary<string, string> stringMap = null, int defaultIndex = -1) where TEnum : Enum
|
||||
{
|
||||
var strings = entries.Select(x => stringMap.Get(x.ToString(), true));
|
||||
comboBox.FillFromEnum(strings, stringMap, defaultIndex);
|
||||
comboBox.FillFromStrings(strings, stringMap, defaultIndex);
|
||||
}
|
||||
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, IEnumerable<TEnum> entries, Dictionary<string, string> stringMap, TEnum defaultEntry) where TEnum : Enum
|
||||
|
@ -324,13 +324,16 @@ namespace Flowframes
|
|||
comboBox.Text = stringMap.Get(defaultEntry.ToString(), true);
|
||||
}
|
||||
|
||||
public static void FillFromEnum(this ComboBox comboBox, IEnumerable<string> entries, Dictionary<string, string> stringMap = null, int defaultIndex = -1)
|
||||
public static void FillFromStrings(this ComboBox comboBox, IEnumerable<string> entries, Dictionary<string, string> stringMap = null, int defaultIndex = -1, IEnumerable<string> exclusionList = null)
|
||||
{
|
||||
if (stringMap == null)
|
||||
stringMap = new Dictionary<string, string>();
|
||||
|
||||
if (exclusionList == null)
|
||||
exclusionList = new List<string>();
|
||||
|
||||
comboBox.Items.Clear();
|
||||
comboBox.Items.AddRange(entries.Select(x => stringMap.Get(x, true)).ToArray());
|
||||
comboBox.Items.AddRange(entries.Select(x => stringMap.Get(x, true)).Except(exclusionList).ToArray());
|
||||
|
||||
if (defaultIndex >= 0 && comboBox.Items.Count > 0)
|
||||
comboBox.SelectedIndex = defaultIndex;
|
||||
|
|
|
@ -118,14 +118,15 @@ namespace Flowframes.Forms.Main
|
|||
infoStrings.Add("Codec");
|
||||
EncoderInfoVideo info = OutputUtils.GetEncoderInfoVideo(encoder);
|
||||
|
||||
bool adjustableQuality = !info.Lossless && info.QualityLevels != null && info.QualityLevels.Count > 0;
|
||||
bool adjustableQuality = !(info.Lossless == true) && info.QualityLevels != null && info.QualityLevels.Count > 0;
|
||||
comboxOutputQuality.Visible = adjustableQuality;
|
||||
comboxOutputQuality.Items.Clear();
|
||||
|
||||
if (info.QualityLevels.Count > 0)
|
||||
{
|
||||
infoStrings.Add("Quality");
|
||||
comboxOutputQuality.FillFromEnum(info.QualityLevels, Strings.VideoQuality, info.QualityDefault);
|
||||
var exclude = info.Lossless == null ? new List<string> { Enums.Encoding.Quality.Common.Lossless.ToString() } : null;
|
||||
comboxOutputQuality.FillFromStrings(info.QualityLevels, Strings.VideoQuality, info.QualityDefault, exclude);
|
||||
}
|
||||
|
||||
var pixelFormats = info.PixelFormats;
|
||||
|
|
|
@ -256,7 +256,7 @@ namespace Flowframes.Media
|
|||
if (enc == Encoder.NvencAv1)
|
||||
{
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-b:v 0 -preset p7 {(crf > 0 ? $"-cq {crf}" : "-tune lossless")}"); // Lossless not supported as of Jan 2023!!
|
||||
args.Add($"-b:v 0 -preset p7 {(crf > 0 ? $"-cq {crf}" : "-tune lossless")}");
|
||||
}
|
||||
|
||||
if (enc == Encoder.Amf264)
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.Os;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Win32Interop.Enums;
|
||||
using static Flowframes.Data.Enums.Encoding;
|
||||
using Encoder = Flowframes.Data.Enums.Encoding.Encoder;
|
||||
using PixFmt = Flowframes.Data.Enums.Encoding.PixelFormat;
|
||||
|
@ -68,6 +63,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityLevels = ParseUtils.GetEnumStrings<Quality.Common>(),
|
||||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
MaxFramerate = 240,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -107,6 +103,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
PixelFormatDefault = PixFmt.Yuv420P10Le,
|
||||
HwAccelerated = true,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -120,6 +117,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityLevels = ParseUtils.GetEnumStrings<Quality.Common>(),
|
||||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
HwAccelerated = true,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -133,6 +131,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityLevels = ParseUtils.GetEnumStrings<Quality.Common>(),
|
||||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
HwAccelerated = true,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -146,6 +145,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityLevels = ParseUtils.GetEnumStrings<Quality.Common>(),
|
||||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
HwAccelerated = true,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@ namespace Flowframes.MiscUtils
|
|||
QualityLevels = ParseUtils.GetEnumStrings<Quality.Common>(),
|
||||
QualityDefault = (int)Quality.Common.VeryHigh,
|
||||
HwAccelerated = true,
|
||||
Lossless = null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue