VideoExtraData improvs, print warning for HDR content with suboptimal encsettings

This commit is contained in:
n00mkrad
2025-12-23 20:01:03 +01:00
parent b01a9984da
commit d550e83ab4
7 changed files with 86 additions and 15 deletions

View File

@@ -1,11 +1,55 @@
namespace Flowframes.Data
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static Flowframes.Data.Enums.Encoding;
using static Flowframes.Data.Enums.Output;
namespace Flowframes.Data
{
public class OutputSettings
{
public Enums.Output.Format Format { get; set; }
public Enums.Encoding.Encoder Encoder { get; set; }
public Enums.Encoding.PixelFormat PixelFormat { get; set; }
public Format Format { get; set; }
public Encoder Encoder { get; set; }
public PixelFormat PixelFormat { get; set; }
public string Quality { get; set; } = "";
public string CustomQuality { get; set; } = "";
public static List<Format> HdrRecommendedFormats { get; set; } = new List<Format>() { Format.Mkv, Format.Mp4, Format.Mov, Format.Images };
public static List<Encoder> HdrRecommendedEncs { get; set; } = new List<Encoder>();
static OutputSettings ()
{
HdrRecommendedEncs = GetHdrRecommEncs();
}
public static List<Encoder> GetHdrRecommEncs ()
{
var l = new List<Encoder>();
var encs = Enum.GetValues(typeof(Encoder)).Cast<Encoder>();
l.Add(encs.FirstOrDefault(e => $"{e}".EndsWith("265")));
l.Add(encs.FirstOrDefault(e => $"{e}".EndsWith("Av1")));
l.Add(encs.FirstOrDefault(e => $"{e}".EndsWith("Vp9")));
l.AddRange(new[] { Encoder.ProResKs, Encoder.Exr });
return l;
}
public string GetHdrNotSuitableReason ()
{
if(!Format.IsOneOf(true, HdrRecommendedFormats))
return $"Output format may not work for HDR. Recommended: {string.Join(" - ", HdrRecommendedFormats.Select(x => Strings.OutputFormat[x.ToString()]))}";
if(Encoder.IsOneOf(true, HdrRecommendedEncs))
return $"Output encoder may not work for HDR. Recommended: {string.Join(" - ", HdrRecommendedEncs.Select(x => Strings.Encoder[x.ToString()]))}";
string pixFmt = Strings.PixelFormat[PixelFormat.ToString()];
var m = Regex.Match(pixFmt, @"(\d+)(?=-bit\b)");
int bitDepth = m.Success ? m.Groups[1].Value.GetInt() : 0;
if(bitDepth < 10)
return "Output Pixel Format may not work for HDR. Recommended: 10-bit or higher.";
return "";
}
}
}

View File

@@ -122,6 +122,7 @@ namespace Flowframes.Data
Logger.Log($"Failed to initialize MediaFile: {e.Message}", true);
}
VideoExtraData = await FfmpegCommands.GetVidExtraInfo(ImportPath);
Initialized = true;
}

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
namespace Flowframes.Data
{
@@ -12,6 +13,7 @@ namespace Flowframes.Data
public string ColRange = "";
public string ColTransfer = "";
public string ColPrimaries = "";
public bool IsHdr => ColPrimaries == "bt2020" && (ColTransfer == "smpte2084" || ColTransfer == "arib-std-b67");
// Sample/Display Aspect Ratios
public string Sar = "";