diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
5 files changed, 180 insertions, 1 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 9651c6e71..aa9842124 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// A class to convert various things to native C# objects
@@ -296,6 +297,8 @@ namespace HandBrake.ApplicationServices.Utilities return VideoEncoder.QuickSync;
case "theora":
return VideoEncoder.Theora;
+ case "hevc":
+ return VideoEncoder.X265;
default:
return VideoEncoder.X264;
}
@@ -324,6 +327,8 @@ namespace HandBrake.ApplicationServices.Utilities return "qsv_h264";
case VideoEncoder.Theora:
return "theora";
+ case VideoEncoder.X265:
+ return "hevc";
default:
return "x264";
}
@@ -429,6 +434,94 @@ namespace HandBrake.ApplicationServices.Utilities #endregion
+ #region x265
+
+ /// <summary>
+ /// Get the x265Preset from a cli parameter
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ /// <returns>
+ /// The x265Preset enum value
+ /// </returns>
+ public static x265Preset Getx265PresetFromCli(string preset)
+ {
+ switch (preset)
+ {
+ case "ultrafast":
+ return x265Preset.Ultrafast;
+ case "superfast":
+ return x265Preset.Superfast;
+ case "veryfast":
+ return x265Preset.VeryFast;
+ case "faster":
+ return x265Preset.Faster;
+ case "fast":
+ return x265Preset.Fast;
+ case "medium":
+ return x265Preset.Medium;
+ case "slow":
+ return x265Preset.Slow;
+ case "slower":
+ return x265Preset.Slower;
+ case "veryslow":
+ return x265Preset.VerySlow;
+ case "placebo":
+ return x265Preset.Placebo;
+ default:
+ return x265Preset.Faster;
+ }
+ }
+
+ /// <summary>
+ /// Get the x265 Profile from the cli
+ /// </summary>
+ /// <param name="profile">
+ /// The preset.
+ /// </param>
+ /// <returns>
+ /// The x265Profile enum value
+ /// </returns>
+ public static x265Profile Getx265ProfileFromCli(string profile)
+ {
+ switch (profile)
+ {
+ case "mainstillpicture":
+ return x265Profile.Mainstillpicture;
+ case "main":
+ return x265Profile.Main;
+ case "main10":
+ return x265Profile.Main10;
+ default:
+ return x265Profile.Main;
+ }
+ }
+
+ /// <summary>
+ /// Get x265Tune enum from a cli string
+ /// </summary>
+ /// <param name="tune">
+ /// The tune.
+ /// </param>
+ /// <returns>
+ /// The x265Tune enum value
+ /// </returns>
+ public static x265Tune Getx265TuneFromCli(string tune)
+ {
+ switch (tune)
+ {
+ case "psnr":
+ return x265Tune.Psnr;
+ case "ssim":
+ return x265Tune.Ssim;
+ default:
+ return x265Tune.Psnr;
+ }
+ }
+
+ #endregion
+
#region File Format
/// <summary>
@@ -450,6 +543,8 @@ namespace HandBrake.ApplicationServices.Utilities return OutputFormat.Mp4;
case "mkv":
return OutputFormat.Mkv;
+ case "x265":
+ return OutputFormat.X265;
}
}
@@ -472,6 +567,8 @@ namespace HandBrake.ApplicationServices.Utilities return "m4v";
case OutputFormat.Mkv:
return "mkv";
+ case OutputFormat.X265:
+ return "x265";
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 67f243432..a4aacac7f 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -135,6 +135,9 @@ namespace HandBrake.ApplicationServices.Utilities case OutputFormat.Mkv:
profile.ContainerName = "av_mkv"; // TODO make part of enum.
break;
+ case OutputFormat.X265:
+ profile.ContainerName = "x265"; // TODO make part of enum.
+ break;
}
// Picture Settings
@@ -196,6 +199,10 @@ namespace HandBrake.ApplicationServices.Utilities profile.X264Tunes.Add("fastdecode");
}
+ profile.X265Preset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);
+ profile.X265Profile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);
+ profile.X265Tunes = new List<string>();
+
// Chapter Markers
profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 25c3a1426..7448f4bc5 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -281,6 +281,10 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");
AddEncodeElement(xmlWriter, "qsvPreset", "string", parsed.QsvPreset.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "h265Profile", "string", parsed.H265Profile.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "x265Preset", "string", parsed.X265Preset.ToString().ToLower());
+ AddEncodeElement(xmlWriter, "x265Tune", "string", parsed.X265Tune.ToString().ToLower());
+
int videoQualityType = 0;
if (parsed.VideoBitrate != null) videoQualityType = 1;
else if (parsed.Quality != null) videoQualityType = 2;
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index b1db2fcaa..8b246b58c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -22,6 +22,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
+ using HandBrake.Interop.Model.Encoding.x265;
/// <summary>
/// Generate a CLI Query for HandBrakeCLI
@@ -435,6 +436,9 @@ namespace HandBrake.ApplicationServices.Utilities default:
query += " -e x264";
break;
+ case VideoEncoder.X265:
+ query += " -e x265";
+ break;
}
switch (task.VideoEncodeRateType)
@@ -457,6 +461,9 @@ namespace HandBrake.ApplicationServices.Utilities case VideoEncoder.Theora:
query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
break;
+ case VideoEncoder.X265:
+ query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
+ break;
}
break;
}
@@ -937,6 +944,36 @@ namespace HandBrake.ApplicationServices.Utilities }
}
+ // X265 Only
+ if (task.VideoEncoder == VideoEncoder.X265)
+ {
+ if (!task.ShowAdvancedTab)
+ {
+ if (task.X265Preset != x265Preset.VeryFast)
+ {
+ query += string.Format(
+ " --x265-preset={0} ", task.X265Preset.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (task.X265Tune != x265Tune.None)
+ {
+ query += string.Format(
+ " --x265-tune=\"{0}\" ", task.X265Tune.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (task.H265Profile != x265Profile.None)
+ {
+ query += string.Format(
+ " --h265-profile={0} ", task.H265Profile.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
+ if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
+ {
+ query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
+ }
+ }
+ }
+
// QSV Only
if (task.VideoEncoder == VideoEncoder.QuickSync)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index 4872d6e7d..a3cfae6fe 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -115,6 +115,9 @@ namespace HandBrake.ApplicationServices.Utilities Match x264Profile = Regex.Match(input, @"--x264-profile([=a-zA-Z0-9\s ]*)");
Match h264Level = Regex.Match(input, @"--h264-level([=a-zA-Z0-9.\s ]*)");
+ Match x265Profile = Regex.Match(input, @"--x265-profile([=a-zA-Z0-9\s ]*)");
+ Match x265Tune = Regex.Match(input, @"--x265-tune([=,a-zA-Z0-9\s ]*)");
+ Match x265Preset = Regex.Match(input, @"--x265-preset([=a-zA-Z0-9\s ]*)");
#endregion
#region Set Varibles
@@ -476,7 +479,38 @@ namespace HandBrake.ApplicationServices.Utilities parsed.X264Tune = Converters.Getx264TuneFromCli(tuneOptions);
}
-
+
+
+
+
+
+
+ if (x265Preset.Success)
+ parsed.X265Preset =
+ Converters.Getx265PresetFromCli(x265Preset.ToString().Replace("--x265-preset", string.Empty).Replace("=", string.Empty).Trim());
+
+ if (h264Profile.Success)
+ parsed.H265Profile =
+ Converters.Getx265ProfileFromCli(h264Profile.ToString().Replace("--h265-profile", string.Empty).Replace("=", string.Empty).Trim());
+
+ if (x265Profile.Success)
+ parsed.H265Profile =
+ Converters.Getx265ProfileFromCli(x265Profile.ToString().Replace("--x265-profile", string.Empty).Replace("=", string.Empty).Trim());
+
+ if (x265Tune.Success)
+ {
+ string tuneOptions =
+ x265Tune.ToString().Replace("--x265-tune", string.Empty).Replace("=", string.Empty).Trim();
+
+ parsed.FastDecode = tuneOptions.Contains("fastdecode");
+
+ // Remove these options. They are not in the dropdown.
+ tuneOptions = tuneOptions.Replace("fastdecode", string.Empty).Replace(
+ ",", string.Empty);
+
+ parsed.X265Tune = Converters.Getx265TuneFromCli(tuneOptions);
+ }
+
#endregion
}
catch (Exception exc)
|