diff --git a/Code/Extensions/ExtensionMethods.cs b/Code/Extensions/ExtensionMethods.cs index b4d9a97..80ebcb4 100644 --- a/Code/Extensions/ExtensionMethods.cs +++ b/Code/Extensions/ExtensionMethods.cs @@ -79,8 +79,7 @@ namespace Flowframes return 0f; string num = str.TrimNumbers(true).Replace(",", "."); - float value; - float.TryParse(num, NumberStyles.Any, CultureInfo.InvariantCulture, out value); + float.TryParse(num, out float value); return value; } diff --git a/Code/Program.cs b/Code/Program.cs index c82cfd0..023d6e8 100644 --- a/Code/Program.cs +++ b/Code/Program.cs @@ -7,6 +7,7 @@ using Flowframes.Os; using Flowframes.Ui; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -35,6 +36,12 @@ namespace Flowframes [STAThread] static void Main() { + var culture = new CultureInfo("en-US"); + Thread.CurrentThread.CurrentCulture = culture; + Thread.CurrentThread.CurrentUICulture = culture; + CultureInfo.DefaultThreadCurrentCulture = culture; + CultureInfo.DefaultThreadCurrentUICulture = culture; + Paths.Init(); Config.Init(); Cleanup(); diff --git a/Code/Ui/GetWebInfo.cs b/Code/Ui/GetWebInfo.cs index 72149a4..397a9f5 100644 --- a/Code/Ui/GetWebInfo.cs +++ b/Code/Ui/GetWebInfo.cs @@ -56,7 +56,6 @@ namespace Flowframes.Ui if (i == 0 || line.Length < 10 || values.Length < 5) continue; string name = values[0].Trim(); string status = values[4].Trim(); - // float amount = float.Parse(values[7], System.Globalization.CultureInfo.InvariantCulture); string tier = values[9].Trim(); if (status.Contains("Active")) diff --git a/Code/Utilities/ColorDataUtils.cs b/Code/Utilities/ColorDataUtils.cs index 5886b5c..e5d9c08 100644 --- a/Code/Utilities/ColorDataUtils.cs +++ b/Code/Utilities/ColorDataUtils.cs @@ -13,187 +13,6 @@ namespace Flowframes.Utilities { class ColorDataUtils { - // public static async Task GetColorData(string path) - // { - // VideoColorData data = new VideoColorData(); - // - // AvProcess.FfprobeSettings settings = new AvProcess.FfprobeSettings() { Args = $"-show_frames -select_streams v:0 -read_intervals \"%+#1\" {path.Wrap()}", LogLevel = "quiet" }; - // string infoFfprobe = await AvProcess.RunFfprobe(settings); - // - // string[] linesFfprobe = infoFfprobe.SplitIntoLines(); - // - // foreach (string line in linesFfprobe) - // { - // if (line.Contains("color_transfer=")) - // data.ColorTransfer = GetColorTransfer(line.Split('=').Last()); - // - // else if (line.Contains("color_space=")) - // data.ColorMatrixCoeffs = GetMatrixCoeffs(line.Split('=').Last()); - // - // else if (line.Contains("color_primaries=")) - // data.ColorPrimaries = GetColorPrimaries(line.Split('=').Last()); - // - // else if (line.Contains("color_range=")) - // data.ColorRange = GetColorRange(line.Split('=').Last()); - // - // else if (line.Contains("red_x=")) - // data.RedX = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("red_y=")) - // data.RedY = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("green_x=")) - // data.GreenX = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("green_y=")) - // data.GreenY = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("blue_x=")) - // data.BlueY = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("blue_y=")) - // data.BlueX = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("white_point_x=")) - // data.WhiteY = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("white_point_y=")) - // data.WhiteX = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("max_luminance=")) - // data.LumaMax = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("min_luminance=")) - // data.LumaMin = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("max_content=")) - // data.MaxCll = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // - // else if (line.Contains("max_average=")) - // data.MaxFall = line.Contains("/") ? FractionToFloat(line.Split('=').Last()) : line.Split('=').Last(); - // } - // - // string infoMkvinfo = await AvProcess.RunMkvInfo($"{path.Wrap()}", OS.NmkoderProcess.ProcessType.Secondary); - // - // if (infoMkvinfo.Contains("+ Video track")) - // { - // string[] lines = infoMkvinfo.Split("+ Video track")[1].Split("+ Track")[0].Split("+ Tags")[0].SplitIntoLines(); - // - // foreach (string line in lines) - // { - // if (line.Contains("+ Colour transfer:")) - // data.ColorTransfer = ValidateNumber(line.Split(':')[1]).GetInt(); - // - // else if (line.Contains("+ Colour matrix coefficients:")) - // data.ColorMatrixCoeffs = ValidateNumber(line.Split(':')[1]).GetInt(); - // - // else if (line.Contains("+ Colour primaries:")) - // data.ColorPrimaries = ValidateNumber(line.Split(':')[1]).GetInt(); - // - // else if (line.Contains("+ Colour range:")) - // data.ColorRange = ValidateNumber(line.Split(':')[1]).GetInt(); - // - // else if (line.Contains("+ Red colour coordinate x:")) - // data.RedX = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Red colour coordinate y:")) - // data.RedY = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Green colour coordinate x:")) - // data.GreenX = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Green colour coordinate y:")) - // data.GreenY = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Blue colour coordinate y:")) - // data.BlueY = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Blue colour coordinate x:")) - // data.BlueX = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ White colour coordinate y:")) - // data.WhiteY = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ White colour coordinate x:")) - // data.WhiteX = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Maximum luminance:")) - // data.LumaMax = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Minimum luminance:")) - // data.LumaMin = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Maximum content light:")) - // data.MaxCll = ValidateNumber(line.Split(':')[1]); - // - // else if (line.Contains("+ Maximum frame light:")) - // data.MaxFall = ValidateNumber(line.Split(':')[1]); - // } - // } - // - // return data; - // } - - private static string FractionToFloat(string fracString) - { - string[] fracNums = fracString.Split('/'); - return ((float)fracNums[0].GetInt() / (float)fracNums[1].GetInt()).ToString("0.#######", new CultureInfo("en-US")); - } - - private static string ValidateNumber(string numStr) - { - return Double.Parse(numStr, NumberStyles.Float, CultureInfo.InvariantCulture).ToString("0.#######", new CultureInfo("en-US")); - } - - // public static async Task SetColorData(string path, VideoColorData d) - // { - // try - // { - // string tmpPath = IoUtils.FilenameSuffix(path, ".tmp"); - // - // List args = new List(); - // - // args.Add($"-o {tmpPath.Wrap()}"); - // args.Add($"--colour-matrix 0:{d.ColorMatrixCoeffs}"); - // args.Add($"--colour-transfer-characteristics 0:{d.ColorTransfer}"); - // args.Add($"--colour-primaries 0:{d.ColorPrimaries}"); - // args.Add($"--colour-range 0:{d.ColorRange}"); - // if (!string.IsNullOrWhiteSpace(d.LumaMax)) args.Add($"--max-luminance 0:{d.LumaMax}"); - // if (!string.IsNullOrWhiteSpace(d.LumaMin)) args.Add($"--min-luminance 0:{d.LumaMin}"); - // if (!string.IsNullOrWhiteSpace(d.RedX)) args.Add($"--chromaticity-coordinates 0:{d.RedX},{d.RedY},{d.GreenX},{d.GreenY},{d.BlueX},{d.BlueY}"); - // if (!string.IsNullOrWhiteSpace(d.RedX)) args.Add($"--white-colour-coordinates 0:{d.WhiteX},{d.WhiteY}"); - // if (!string.IsNullOrWhiteSpace(d.MaxCll)) args.Add($"--max-content-light 0:{d.MaxCll}"); - // if (!string.IsNullOrWhiteSpace(d.MaxFall)) args.Add($"--max-frame-light 0:{d.MaxFall}"); - // args.Add($"{path.Wrap()}"); - // - // await AvProcess.RunMkvMerge(string.Join(" ", args), OS.NmkoderProcess.ProcessType.Primary, true); - // - // if (!File.Exists(tmpPath)) - // { - // Logger.Log($"Error: Muxing failed."); - // return; - // } - // - // int filesizeDiffKb = (int)((Math.Abs(new FileInfo(path).Length - new FileInfo(tmpPath).Length)) / 1024); - // double filesizeFactor = (double)(new FileInfo(tmpPath).Length) / (double)(new FileInfo(path).Length); - // Logger.Log($"{MethodBase.GetCurrentMethod().DeclaringType}: Filesize ratio of remuxed file against original: {filesizeFactor}", true); - // - // if (filesizeDiffKb > 1024 && (filesizeFactor < 0.95d || filesizeFactor > 1.05d)) - // { - // Logger.Log($"Warning: Output file size differs by >1MB is not within 5% of the original file's size! Won't delete original to be sure."); - // } - // else - // { - // File.Delete(path); - // File.Move(tmpPath, path); - // } - // } - // catch (Exception e) - // { - // Logger.Log($"SetColorData Error: {e.Message}\n{e.StackTrace}"); - // } - // } - public static int GetColorPrimaries(string s) // Defined by the "Color primaries" section of ISO/IEC 23091-4/ITU-T H.273 { s = s.Trim().ToLowerInvariant();