private string Convert() { string input = textBoxIn.Text; string output = textBoxOut.Text; if (string.IsNullOrWhiteSpace(input)) { return("No input file!"); } if (string.IsNullOrWhiteSpace(output)) { return("No output file!"); } if (invalidChars.Any(input.Contains)) { return("Input path contains invalid characters!\nInvalid characters: " + string.Join(" ", invalidChars)); } if (invalidChars.Any(output.Contains)) { return("Output path contains invalid characters!\nInvalid characters: " + string.Join(" ", invalidChars)); } if (!File.Exists(input)) { return("Input file doesn't exist!"); } if (input == output) { return("Input and output files are the same!"); } float startSeconds, endSeconds; try { startSeconds = ParseTime(boxCropFrom.Text); } catch (ArgumentException) { return("Invalid start crop time!"); } try { endSeconds = ParseTime(boxCropTo.Text); } catch (ArgumentException) { return("Invalid end crop time!"); } string options = textBoxArguments.Text; try { if (options.Trim() == "" || _argumentError) { options = GenerateArguments(); } } catch (ArgumentException e) { return(e.Message); } string start = ""; string end = ""; if (startSeconds != 0.0) { start = "-ss " + startSeconds.ToString(CultureInfo.InvariantCulture); //Convert comma to dot } float duration = 0; if (endSeconds != 0.0) { duration = endSeconds - startSeconds; if (duration <= 0) { return("Video is 0 or less seconds long!"); } end = "-to " + duration.ToString(CultureInfo.InvariantCulture); //Convert comma to dot } string[] arguments; if (!checkBox2Pass.Checked) { arguments = new[] { string.Format(_template, input, output, start, end, options, "", "") } } ; else { int passes = 2; //Can you even use more than 2 passes? string HQ = ""; if (boxHQ.Checked) { HQ = "-auto-alt-ref 1"; //This should improve quality, only in 2-pass mode } arguments = new string[passes]; for (int i = 0; i < passes; i++) { arguments[i] = string.Format(_template, input, output, start, end, options, "-pass " + (i + 1), HQ); } } var form = new ConverterForm(this, arguments); form.ShowDialog(); return(null); }
private string Convert() { string input = textBoxIn.Text; string output = textBoxOut.Text; if (string.IsNullOrWhiteSpace(input)) return "No input file!"; if (string.IsNullOrWhiteSpace(output)) return "No output file!"; if (invalidChars.Any(input.Contains)) return "Input path contains invalid characters!\nInvalid characters: " + string.Join(" ", invalidChars); if (invalidChars.Any(output.Contains)) return "Output path contains invalid characters!\nInvalid characters: " + string.Join(" ", invalidChars); if (!File.Exists(input)) return "Input file doesn't exist!"; if (input == output) return "Input and output files are the same!"; float startSeconds, endSeconds; try { startSeconds = ParseTime(boxCropFrom.Text); } catch (ArgumentException) { return "Invalid start crop time!"; } try { endSeconds = ParseTime(boxCropTo.Text); } catch (ArgumentException) { return "Invalid end crop time!"; } string options = textBoxArguments.Text; try { if (options.Trim() == "" || _argumentError) options = GenerateArguments(); } catch (ArgumentException e) { return e.Message; } string start = ""; string end = ""; if (startSeconds != 0.0) { start = "-ss " + startSeconds.ToString(CultureInfo.InvariantCulture); //Convert comma to dot } float duration = 0; if (endSeconds != 0.0) { duration = endSeconds - startSeconds; if (duration <= 0) return "Video is 0 or less seconds long!"; end = "-to " + duration.ToString(CultureInfo.InvariantCulture); //Convert comma to dot } string[] arguments; if (!checkBox2Pass.Checked) arguments = new[] { string.Format(_template, input, output, start, end, options, "", "") }; else { int passes = 2; //Can you even use more than 2 passes? string HQ = ""; if (boxHQ.Checked) HQ = "-auto-alt-ref 1"; //This should improve quality, only in 2-pass mode arguments = new string[passes]; for (int i = 0; i < passes; i++) arguments[i] = string.Format(_template, input, output, start, end, options, "-pass " + (i + 1), HQ); } var form = new ConverterForm(this, arguments); form.ShowDialog(); return null; }