mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Fix culture to en-US across entire program to avoid parsing issues etc
This commit is contained in:
@@ -79,8 +79,7 @@ namespace Flowframes
|
|||||||
return 0f;
|
return 0f;
|
||||||
|
|
||||||
string num = str.TrimNumbers(true).Replace(",", ".");
|
string num = str.TrimNumbers(true).Replace(",", ".");
|
||||||
float value;
|
float.TryParse(num, out float value);
|
||||||
float.TryParse(num, NumberStyles.Any, CultureInfo.InvariantCulture, out value);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Flowframes.Os;
|
|||||||
using Flowframes.Ui;
|
using Flowframes.Ui;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -35,6 +36,12 @@ namespace Flowframes
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
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();
|
Paths.Init();
|
||||||
Config.Init();
|
Config.Init();
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ namespace Flowframes.Ui
|
|||||||
if (i == 0 || line.Length < 10 || values.Length < 5) continue;
|
if (i == 0 || line.Length < 10 || values.Length < 5) continue;
|
||||||
string name = values[0].Trim();
|
string name = values[0].Trim();
|
||||||
string status = values[4].Trim();
|
string status = values[4].Trim();
|
||||||
// float amount = float.Parse(values[7], System.Globalization.CultureInfo.InvariantCulture);
|
|
||||||
string tier = values[9].Trim();
|
string tier = values[9].Trim();
|
||||||
|
|
||||||
if (status.Contains("Active"))
|
if (status.Contains("Active"))
|
||||||
|
|||||||
@@ -13,187 +13,6 @@ namespace Flowframes.Utilities
|
|||||||
{
|
{
|
||||||
class ColorDataUtils
|
class ColorDataUtils
|
||||||
{
|
{
|
||||||
// public static async Task<VideoColorData> 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<string> args = new List<string>();
|
|
||||||
//
|
|
||||||
// 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
|
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();
|
s = s.Trim().ToLowerInvariant();
|
||||||
|
|||||||
Reference in New Issue
Block a user