/* QueryParser.cs $\r
- \r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr>.\r
- It may be used under the terms of the GNU General Public License. */\r
-\r
-using System;\r
-using System.Globalization;\r
-using System.Text.RegularExpressions;\r
-using System.Windows.Forms;\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
\r
namespace Handbrake.Functions\r
{\r
- internal class QueryParser\r
+ using System;\r
+ using System.Collections;\r
+ using System.Globalization;\r
+ using System.Text.RegularExpressions;\r
+ using System.Windows.Forms;\r
+ using Model;\r
+\r
+ /// <summary>\r
+ /// Parse a CLI Query\r
+ /// </summary>\r
+ public class QueryParser\r
{\r
+ /// <summary>\r
+ /// The Culture\r
+ /// </summary>\r
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
\r
#region Varibles\r
\r
- #region Source\r
- public int DVDTitle { get; private set; }\r
- public int DVDChapterStart { get; private set; }\r
- public int DVDChapterFinish { get; private set; }\r
+ #region Source Title / Chapters\r
+ /// <summary>\r
+ /// Gets or sets Title.\r
+ /// </summary>\r
+ public int Title { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets ChapterStart.\r
+ /// </summary>\r
+ public int ChapterStart { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets ChapterFinish.\r
+ /// </summary>\r
+ public int ChapterFinish { get; set; }\r
#endregion\r
\r
#region Output Settings\r
- public string Format { get; private set; }\r
- public Boolean LargeMP4 { get; private set; }\r
- public Boolean IpodAtom { get; private set; }\r
- public Boolean OptimizeMP4 { get; private set; }\r
+ /// <summary>\r
+ /// Gets or sets the file Format. e.g mkv or mp4\r
+ /// </summary>\r
+ public string Format { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether LargeMP4 support is enabled.\r
+ /// This is the 64bit MP4 file that allows >4GB files\r
+ /// </summary>\r
+ public bool LargeMP4 { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether IpodAtom is inserted\r
+ /// </summary>\r
+ public bool IpodAtom { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether OptimizeMP4 is enabed for web streaming\r
+ /// </summary>\r
+ public bool OptimizeMP4 { get; set; }\r
#endregion\r
\r
#region Picture Settings\r
- public int Width { get; private set; }\r
- public int Height { get; private set; }\r
- public int MaxWidth { get; private set; }\r
- public int MaxHeight { get; private set; }\r
- public string CropValues { get; private set; }\r
- public string CropTop { get; private set; }\r
- public string CropBottom { get; private set; }\r
- public string CropLeft { get; private set; }\r
- public string CropRight { get; private set; }\r
- public Boolean Anamorphic { get; private set; }\r
- public Boolean LooseAnamorphic { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Width.\r
+ /// </summary>\r
+ public int Width { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Height.\r
+ /// </summary>\r
+ public int Height { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets MaxWidth.\r
+ /// </summary>\r
+ public int MaxWidth { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets MaxHeight.\r
+ /// </summary>\r
+ public int MaxHeight { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CropValues.\r
+ /// </summary>\r
+ public string CropValues { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CropTop.\r
+ /// </summary>\r
+ public string CropTop { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CropBottom.\r
+ /// </summary>\r
+ public string CropBottom { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CropLeft.\r
+ /// </summary>\r
+ public string CropLeft { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets CropRight.\r
+ /// </summary>\r
+ public string CropRight { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets AnamorphicMode.\r
+ /// </summary>\r
+ public int AnamorphicMode { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether KeepDisplayAsect.\r
+ /// </summary>\r
+ public bool KeepDisplayAsect { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets DisplayWidthValue.\r
+ /// </summary>\r
+ public double DisplayWidthValue { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PixelAspectWidth.\r
+ /// </summary>\r
+ public int PixelAspectWidth { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PixelAspectHeight.\r
+ /// </summary>\r
+ public int PixelAspectHeight { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets AnamorphicModulus.\r
+ /// </summary>\r
+ public int AnamorphicModulus { get; set; }\r
#endregion\r
\r
#region Video Filters\r
- public string DeTelecine { get; private set; }\r
- public int DeBlock { get; private set; }\r
- public string DeInterlace { get; private set; }\r
- public string DeNoise { get; private set; }\r
- public string Decomb { get; private set; }\r
- #endregion \r
+\r
+ /// <summary>\r
+ /// Gets or sets DeTelecine.\r
+ /// </summary>\r
+ public string DeTelecine { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets DeBlock.\r
+ /// </summary>\r
+ public int DeBlock { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets DeInterlace.\r
+ /// </summary>\r
+ public string DeInterlace { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets DeNoise.\r
+ /// </summary>\r
+ public string DeNoise { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Decomb.\r
+ /// </summary>\r
+ public string Decomb { get; set; }\r
+ #endregion\r
\r
#region Video Settings\r
- public string VideoEncoder { get; private set; }\r
- public Boolean Grayscale { get; private set; }\r
- public Boolean TwoPass { get; private set; }\r
- public Boolean TurboFirstPass { get; private set; }\r
- public string VideoFramerate { get; private set; }\r
- public string AverageVideoBitrate { get; private set; }\r
- public string VideoTargetSize { get; private set; }\r
- public float VideoQuality { get; private set; }\r
+ /// <summary>\r
+ /// Gets or sets VideoEncoder.\r
+ /// </summary>\r
+ public string VideoEncoder { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether Grayscale.\r
+ /// </summary>\r
+ public bool Grayscale { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether TwoPass.\r
+ /// </summary>\r
+ public bool TwoPass { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether TurboFirstPass.\r
+ /// </summary>\r
+ public bool TurboFirstPass { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets VideoFramerate.\r
+ /// </summary>\r
+ public string VideoFramerate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets AverageVideoBitrate.\r
+ /// </summary>\r
+ public string AverageVideoBitrate { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets VideoTargetSize.\r
+ /// </summary>\r
+ public string VideoTargetSize { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets VideoQuality.\r
+ /// </summary>\r
+ public float VideoQuality { get; set; }\r
#endregion\r
\r
#region Audio Settings\r
- public string AudioTrack1 { get; private set; }\r
- public string AudioTrack2 { get; private set; }\r
- public string AudioTrack3 { get; private set; }\r
- public string AudioTrack4 { get; private set; }\r
- public string AudioTrackMix1 { get; private set; }\r
- public string AudioTrackMix2 { get; private set; }\r
- public string AudioTrackMix3 { get; private set; }\r
- public string AudioTrackMix4 { get; private set; }\r
- public string AudioEncoder1 { get; private set; }\r
- public string AudioEncoder2 { get; private set; }\r
- public string AudioEncoder3 { get; private set; }\r
- public string AudioEncoder4 { get; private set; }\r
- public string AudioBitrate1 { get; private set; }\r
- public string AudioBitrate2 { get; private set; }\r
- public string AudioBitrate3 { get; private set; }\r
- public string AudioBitrate4 { get; private set; }\r
- public string AudioSamplerate1 { get; private set; }\r
- public string AudioSamplerate2 { get; private set; }\r
- public string AudioSamplerate3 { get; private set; }\r
- public string AudioSamplerate4 { get; private set; }\r
- public double DRC1 { get; private set; }\r
- public double DRC2 { get; private set; }\r
- public double DRC3 { get; private set; }\r
- public double DRC4 { get; private set; }\r
- public string Subtitles { get; private set; }\r
- public Boolean ForcedSubtitles { get; private set; }\r
- #endregion\r
\r
- #region Chapter Markers\r
- public Boolean ChapterMarkers { get; private set; }\r
+ /// <summary>\r
+ /// Gets or sets AudioInformation.\r
+ /// </summary>\r
+ public ArrayList AudioInformation { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Subtitles.\r
+ /// </summary>\r
+ public string Subtitles { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether ForcedSubtitles.\r
+ /// </summary>\r
+ public bool ForcedSubtitles { get; set; }\r
#endregion\r
\r
#region Other\r
- public string H264Query { get; private set; }\r
- public Boolean Verbose { get; private set; }\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether ChapterMarkers.\r
+ /// </summary>\r
+ public bool ChapterMarkers { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets H264Query.\r
+ /// </summary>\r
+ public string H264Query { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether Verbose.\r
+ /// </summary>\r
+ public bool Verbose { get; set; }\r
+ #endregion\r
+\r
+ #region Preset Information\r
+\r
+ /// <summary>\r
+ /// Gets or sets PresetBuildNumber.\r
+ /// </summary>\r
+ public int PresetBuildNumber { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PresetDescription.\r
+ /// </summary>\r
+ public string PresetDescription { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets PresetName.\r
+ /// </summary>\r
+ public string PresetName { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets Type.\r
+ /// </summary>\r
+ public string Type { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether UsesMaxPictureSettings.\r
+ /// </summary>\r
+ public bool UsesMaxPictureSettings { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether UsesPictureFilters.\r
+ /// </summary>\r
+ public bool UsesPictureFilters { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether UsesPictureSettings.\r
+ /// </summary>\r
+ public bool UsesPictureSettings { get; set; }\r
#endregion\r
\r
#endregion\r
\r
- // All the Main Window GUI options\r
/// <summary>\r
/// Takes in a query which can be in any order and parses it. \r
/// All varibles are then set so they can be used elsewhere.\r
/// </summary>\r
/// <param name="input">A ClI Query</param>\r
/// <returns>A Parsed Query</returns>\r
- public static QueryParser Parse(String input)\r
+ public static QueryParser Parse(string input)\r
{\r
var thisQuery = new QueryParser();\r
\r
#region Regular Expressions\r
\r
- // Useful Destination Finder\r
- //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");\r
- //Match source = r1.Match(input.Replace('"', '\"'));\r
-\r
- //Source\r
+ // Source\r
Match title = Regex.Match(input, @"-t ([0-9]*)");\r
Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
- \r
- //Output Settings\r
+\r
+ // Output Settings\r
Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
Match grayscale = Regex.Match(input, @" -g");\r
Match largerMp4 = Regex.Match(input, @" -4");\r
Match ipodAtom = Regex.Match(input, @" -I");\r
\r
- //Picture Settings Tab\r
+ // Picture Settings Tab\r
Match width = Regex.Match(input, @"-w ([0-9]*)");\r
Match height = Regex.Match(input, @"-l ([0-9]*)");\r
Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");\r
Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");\r
Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");\r
- Match lanamorphic = Regex.Match(input, @" -P");\r
- Match anamorphic = Regex.Match(input, @" -p ");\r
+\r
+ Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");\r
+ Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");\r
+ Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");\r
+\r
+ Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");\r
+ Match displayWidth = Regex.Match(input, @"--display-width ([0-9]*)");\r
+ Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");\r
+ Match modulus = Regex.Match(input, @"--modulus ([0-9]*)");\r
\r
// Picture Settings - Filters\r
Match decomb = Regex.Match(input, @" --decomb");\r
Match detelecine = Regex.Match(input, @"--detelecine");\r
Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");\r
\r
- //Video Settings Tab\r
+ // Video Settings Tab\r
Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
Match videoFramerate = Regex.Match(input, @"-r ([0-9.]*)");\r
Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");\r
Match turboFirstPass = Regex.Match(input, @" -T");\r
Match optimizeMP4 = Regex.Match(input, @" -O");\r
\r
- //Audio Settings Tab\r
+ // Audio Settings Tab\r
Match noAudio = Regex.Match(input, @"-a none");\r
- Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");\r
- Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");\r
- Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");\r
- Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");\r
-\r
- Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z]*)");\r
- Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*)");\r
- Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*),([0-9a-z]*)");\r
- Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z]*),([0-9a-z]*),([0-9a-z]*),([0-9a-z]*)");\r
-\r
- Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");\r
- Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
- Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
- Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
-\r
- Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");\r
- Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");\r
- Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");\r
- Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");\r
-\r
- Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");\r
- Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");\r
- Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");\r
- Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");\r
-\r
- Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");\r
- Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");\r
- Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");\r
- Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");\r
+ Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)");\r
+ Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)");\r
+ Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,]*)");\r
+ Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)"); // Auto = a-z\r
+ Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z\r
+ Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");\r
\r
Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");\r
Match subScan = Regex.Match(input, @" -U");\r
Match chapterMarkers = Regex.Match(input, @" -m");\r
Match chapterMarkersFileMode = Regex.Match(input, @"--markers");\r
\r
- //H264 Tab\r
+ // H264 Tab\r
Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");\r
\r
- //Program Options\r
+ // Program Options\r
Match verbose = Regex.Match(input, @" -v");\r
\r
#endregion\r
#region Source Tab\r
\r
if (title.Success)\r
- thisQuery.DVDTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
+ thisQuery.Title = int.Parse(title.ToString().Replace("-t ", string.Empty));\r
\r
if (chapters.Success)\r
{\r
- string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
- thisQuery.DVDChapterStart = int.Parse(actTitles[0]);\r
+ string[] actTitles = chapters.ToString().Replace("-c ", string.Empty).Split('-');\r
+ thisQuery.ChapterStart = int.Parse(actTitles[0]);\r
if (actTitles.Length > 1)\r
{\r
- thisQuery.DVDChapterFinish = int.Parse(actTitles[1]);\r
+ thisQuery.ChapterFinish = int.Parse(actTitles[1]);\r
}\r
\r
- if ((thisQuery.DVDChapterStart == 1) && (thisQuery.DVDChapterFinish == 0))\r
- thisQuery.DVDChapterFinish = thisQuery.DVDChapterStart;\r
+ if ((thisQuery.ChapterStart == 1) && (thisQuery.ChapterFinish == 0))\r
+ thisQuery.ChapterFinish = thisQuery.ChapterStart;\r
}\r
+\r
#endregion\r
\r
#region Output Settings\r
\r
if (format.Success)\r
- thisQuery.Format = format.ToString().Replace("-f ", "");\r
+ thisQuery.Format = format.ToString().Replace("-f ", string.Empty);\r
thisQuery.LargeMP4 = largerMp4.Success;\r
thisQuery.IpodAtom = ipodAtom.Success;\r
thisQuery.OptimizeMP4 = optimizeMP4.Success;\r
#region Picture Tab\r
\r
if (width.Success)\r
- thisQuery.Width = int.Parse(width.ToString().Replace("-w ", ""));\r
+ thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", string.Empty));\r
\r
if (height.Success)\r
- thisQuery.Height = int.Parse(height.ToString().Replace("-l ", ""));\r
+ thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", string.Empty));\r
\r
if (maxWidth.Success)\r
- thisQuery.MaxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));\r
+ thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", string.Empty));\r
\r
if (maxHeight.Success)\r
- thisQuery.MaxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));\r
+ thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", string.Empty));\r
\r
if (crop.Success)\r
{\r
- thisQuery.CropValues = crop.ToString().Replace("--crop ", "");\r
+ thisQuery.CropValues = crop.ToString().Replace("--crop ", string.Empty);\r
string[] actCropValues = thisQuery.CropValues.Split(':');\r
thisQuery.CropTop = actCropValues[0];\r
thisQuery.CropBottom = actCropValues[1];\r
thisQuery.CropLeft = actCropValues[2];\r
thisQuery.CropRight = actCropValues[3];\r
}\r
- \r
- thisQuery.Anamorphic = anamorphic.Success;\r
- thisQuery.LooseAnamorphic = lanamorphic.Success;\r
+\r
+ if (strictAnamorphic.Success)\r
+ thisQuery.AnamorphicMode = 1;\r
+ else if (looseAnamorphic.Success)\r
+ thisQuery.AnamorphicMode = 2;\r
+ else if (customAnamorphic.Success)\r
+ thisQuery.AnamorphicMode = 3;\r
+ else\r
+ thisQuery.AnamorphicMode = 0;\r
+\r
+ thisQuery.KeepDisplayAsect = keepDisplayAsect.Success;\r
+\r
+ if (displayWidth.Success)\r
+ thisQuery.DisplayWidthValue =\r
+ double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", string.Empty));\r
+\r
+ if (pixelAspect.Success)\r
+ thisQuery.PixelAspectWidth = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", string.Empty));\r
+\r
+ if (pixelAspect.Success && pixelAspect.Groups.Count >= 3)\r
+ thisQuery.PixelAspectHeight = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", string.Empty));\r
+\r
+ if (modulus.Success)\r
+ thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", string.Empty));\r
\r
#endregion\r
\r
{\r
thisQuery.Decomb = "Default";\r
if (decombValue.Success)\r
- thisQuery.Decomb = decombValue.ToString().Replace("--decomb=", "").Replace("\"", "");\r
+ thisQuery.Decomb = decombValue.ToString().Replace("--decomb=", string.Empty).Replace("\"", string.Empty);\r
}\r
\r
- thisQuery.DeInterlace = "None";\r
+ thisQuery.DeInterlace = "Off";\r
if (deinterlace.Success)\r
{\r
- thisQuery.DeInterlace = deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"", "");\r
- thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");\r
+ thisQuery.DeInterlace = deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty);\r
+ thisQuery.DeInterlace =\r
+ thisQuery.DeInterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");\r
thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("slowest", "Slowest");\r
}\r
\r
- thisQuery.DeNoise = "None";\r
+ thisQuery.DeNoise = "Off";\r
if (denoise.Success)\r
{\r
- thisQuery.DeNoise = denoise.ToString().Replace("--denoise=", "").Replace("\"", "");\r
- thisQuery.DeNoise = thisQuery.DeNoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");\r
+ thisQuery.DeNoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty);\r
+ thisQuery.DeNoise =\r
+ thisQuery.DeNoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");\r
}\r
\r
- string deblockValue = "";\r
+ string deblockValue = string.Empty;\r
thisQuery.DeBlock = 0;\r
if (deblock.Success)\r
- deblockValue = deblock.ToString().Replace("--deblock=", "");\r
+ deblockValue = deblock.ToString().Replace("--deblock=", string.Empty);\r
\r
int dval = 0;\r
- if (deblockValue != "")\r
+ if (deblockValue != string.Empty)\r
int.TryParse(deblockValue, out dval);\r
thisQuery.DeBlock = dval;\r
\r
{\r
thisQuery.DeTelecine = "Default";\r
if (detelecineValue.Success)\r
- thisQuery.DeTelecine = detelecineValue.ToString().Replace("--detelecine=", "").Replace("\"", "");\r
+ thisQuery.DeTelecine = detelecineValue.ToString().Replace("--detelecine=", string.Empty).Replace("\"", string.Empty);\r
}\r
\r
#endregion\r
\r
#region Video Settings Tab\r
\r
- string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
+ string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", string.Empty);\r
switch (videoEncoderConvertion)\r
{\r
case "ffmpeg":\r
break;\r
}\r
thisQuery.VideoEncoder = videoEncoderConvertion;\r
- thisQuery.VideoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";\r
+ thisQuery.VideoFramerate = videoFramerate.Success\r
+ ? videoFramerate.ToString().Replace("-r ", string.Empty)\r
+ : "Same as source";\r
thisQuery.Grayscale = grayscale.Success;\r
thisQuery.TwoPass = twoPass.Success;\r
thisQuery.TurboFirstPass = turboFirstPass.Success;\r
- \r
+\r
if (videoBitrate.Success)\r
- thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", "");\r
+ thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", string.Empty);\r
if (videoFilesize.Success)\r
- thisQuery.VideoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
+ thisQuery.VideoTargetSize = videoFilesize.ToString().Replace("-S ", string.Empty);\r
\r
if (videoQuality.Success)\r
{\r
- float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);\r
- //qConvert = Math.Ceiling(qConvert);\r
+ float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", string.Empty), Culture);\r
thisQuery.VideoQuality = qConvert;\r
}\r
- #endregion\r
-\r
- #region Audio Tab\r
-\r
- // Tracks\r
- if (noAudio.Success)\r
- thisQuery.AudioTrack1 = "None";\r
- else if (audioTrack1.Success)\r
- thisQuery.AudioTrack1 = "Automatic";\r
-\r
- if (audioTrack2.Success)\r
- {\r
- string[] audioChan = audioTrack2.ToString().Split(',');\r
- thisQuery.AudioTrack2 = audioChan[1];\r
- }\r
- else\r
- thisQuery.AudioTrack2 = "None";\r
-\r
- if (audioTrack3.Success)\r
- {\r
- string[] audioChan = audioTrack3.ToString().Split(',');\r
- thisQuery.AudioTrack3 = audioChan[2];\r
- }\r
- else\r
- thisQuery.AudioTrack3 = "None";\r
-\r
- if (audioTrack4.Success)\r
- {\r
- string[] audioChan = audioTrack4.ToString().Split(',');\r
- thisQuery.AudioTrack4 = audioChan[3];\r
- }\r
else\r
- thisQuery.AudioTrack4 = "None";\r
+ thisQuery.VideoQuality = -1;\r
\r
+ #endregion\r
\r
- // Mixdowns\r
- thisQuery.AudioTrackMix1 = "Automatic";\r
- if (audioTrack1Mix.Success)\r
- thisQuery.AudioTrackMix1 =\r
- getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));\r
-\r
- thisQuery.AudioTrackMix2 = "Automatic";\r
- if (audioTrack2Mix.Success)\r
- {\r
- string[] audio2mix = audioTrack2Mix.ToString().Split(',');\r
- thisQuery.AudioTrackMix2 = getMixDown(audio2mix[1].Trim());\r
- }\r
-\r
- thisQuery.AudioTrackMix3 = "Automatic";\r
- if (audioTrack3Mix.Success)\r
- {\r
- string[] audio3mix = audioTrack3Mix.ToString().Split(',');\r
- thisQuery.AudioTrackMix3 = getMixDown(audio3mix[2].Trim());\r
- }\r
-\r
- thisQuery.AudioTrackMix4 = "Automatic";\r
- if (audioTrack4Mix.Success)\r
- {\r
- string[] audio4mix = audioTrack4Mix.ToString().Split(',');\r
- thisQuery.AudioTrackMix4 = getMixDown(audio4mix[3].Trim());\r
- }\r
-\r
-\r
- // Audio Encoders\r
- if (audioEncoder1.Success)\r
- thisQuery.AudioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));\r
-\r
- if (audioEncoder2.Success)\r
- {\r
- string[] audio2enc = audioEncoder2.ToString().Split(',');\r
- thisQuery.AudioEncoder2 = getAudioEncoder(audio2enc[1].Trim());\r
- }\r
-\r
- if (audioEncoder3.Success)\r
- {\r
- string[] audio3enc = audioEncoder3.ToString().Split(',');\r
- thisQuery.AudioEncoder3 = getAudioEncoder(audio3enc[2].Trim());\r
- }\r
-\r
- if (audioEncoder4.Success)\r
- {\r
- string[] audio4enc = audioEncoder4.ToString().Split(',');\r
- thisQuery.AudioEncoder4 = getAudioEncoder(audio4enc[3].Trim());\r
- }\r
-\r
-\r
- // Audio Bitrate\r
- thisQuery.AudioBitrate1 = "";\r
- if (audioBitrate1.Success)\r
- {\r
- thisQuery.AudioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();\r
- if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.AudioBitrate1 = "Auto";\r
- }\r
-\r
- thisQuery.AudioBitrate2 = "";\r
- if (audioBitrate2.Success && audioTrack2.Success)\r
- {\r
- string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');\r
- if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";\r
- thisQuery.AudioBitrate2 = audioBitrateSelect[1].Trim();\r
- }\r
-\r
- thisQuery.AudioBitrate3 = "";\r
- if (audioBitrate3.Success && audioTrack3.Success)\r
- {\r
- string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');\r
- if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";\r
- thisQuery.AudioBitrate3 = audioBitrateSelect[2].Trim();\r
- }\r
-\r
- thisQuery.AudioBitrate4 = "";\r
- if (audioBitrate4.Success)\r
- {\r
- string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');\r
- if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";\r
- thisQuery.AudioBitrate4 = audioBitrateSelect[3].Trim();\r
- }\r
-\r
-\r
- // Audio Sample Rate\r
- // Make sure to change 0 to Auto\r
- thisQuery.AudioSamplerate1 = "Auto";\r
- if (audioSampleRate1.Success)\r
- {\r
- thisQuery.AudioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();\r
- if (thisQuery.AudioSamplerate1 == "0") thisQuery.AudioSamplerate1 = "Auto";\r
- }\r
-\r
+ #region Audio Tab\r
\r
- if (audioSampleRate2.Success)\r
+ // Find out how many tracks we need to add by checking how many encoders or audio tracks are selected.\r
+ int encoderCount = 0;\r
+ if (audioEncoders.Success)\r
{\r
- string[] audioSRSelect = audioSampleRate2.ToString().Split(',');\r
- if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";\r
- thisQuery.AudioSamplerate2 = audioSRSelect[1].Trim();\r
+ string[] audioDataCounters = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');\r
+ encoderCount = audioDataCounters.Length;\r
}\r
\r
- if (audioSampleRate3.Success)\r
+ // Get the data from the regular expression results\r
+ string[] trackData = null;\r
+ string[] trackMixes = null;\r
+ string[] trackEncoders = null;\r
+ string[] trackBitrates = null;\r
+ string[] trackSamplerates = null;\r
+ string[] trackDRCvalues = null;\r
+\r
+ if (audioTracks.Success)\r
+ trackData = audioTracks.ToString().Replace("-a ", string.Empty).Split(',');\r
+ if (audioTrackMixes.Success)\r
+ trackMixes = audioTrackMixes.ToString().Replace("-6 ", string.Empty).Split(',');\r
+ if (audioEncoders.Success)\r
+ trackEncoders = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');\r
+ if (audioBitrates.Success)\r
+ trackBitrates = audioBitrates.ToString().Replace("-B ", string.Empty).Split(',');\r
+ if (audioSampleRates.Success)\r
+ trackSamplerates = audioSampleRates.ToString().Replace("-R ", string.Empty).Split(',');\r
+ if (drcValues.Success)\r
+ trackDRCvalues = drcValues.ToString().Replace("-D ", string.Empty).Split(',');\r
+\r
+ // Create new Audio Track Classes and store them in the ArrayList\r
+ ArrayList allAudioTrackInfo = new ArrayList();\r
+ for (int x = 0; x < encoderCount; x++)\r
{\r
- string[] audioSRSelect = audioSampleRate3.ToString().Split(',');\r
- if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";\r
- thisQuery.AudioSamplerate3 = audioSRSelect[2].Trim();\r
- }\r
+ AudioTrack track = new AudioTrack();\r
+ if (trackData != null)\r
+ if (trackData.Length >= (x + 1)) // Audio Track\r
+ track.Track = trackData[x].Trim();\r
\r
- if (audioSampleRate4.Success)\r
- {\r
- string[] audioSRSelect = audioSampleRate4.ToString().Split(',');\r
- if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";\r
- thisQuery.AudioSamplerate4 = audioSRSelect[3].Trim();\r
- }\r
+ if (trackMixes != null)\r
+ if (trackMixes.Length >= (x + 1)) // Audio Mix\r
+ track.MixDown = GetMixDown(trackMixes[x].Trim());\r
\r
- // DRC\r
- float drcValue;\r
+ if (trackEncoders != null)\r
+ if (trackEncoders.Length >= (x + 1)) // Audio Mix\r
+ track.Encoder = GetAudioEncoder(trackEncoders[x].Trim());\r
\r
- thisQuery.DRC1 = 1;\r
- if (drc1.Success)\r
- {\r
- string value = drc1.ToString().Replace("-D ", "");\r
- float.TryParse(value, out drcValue);\r
- thisQuery.DRC1 = drcValue;\r
- }\r
+ if (trackBitrates != null)\r
+ if (trackBitrates.Length >= (x + 1)) // Audio Encoder\r
+ track.Bitrate = trackBitrates[x].Trim() == "auto" ? "Auto" : trackBitrates[x].Trim();\r
\r
- thisQuery.DRC2 = 1;\r
- if (drc2.Success)\r
- {\r
- string[] drcPoint = drc2.ToString().Split(',');\r
- float.TryParse(drcPoint[1], out drcValue);\r
- thisQuery.DRC2 = drcValue;\r
- }\r
+ if (trackSamplerates != null)\r
+ if (trackSamplerates.Length >= (x + 1)) // Audio SampleRate\r
+ track.SampleRate = trackSamplerates[x].Trim() == "0" ? "Auto" : trackSamplerates[x].Trim();\r
\r
- thisQuery.DRC3 = 1;\r
- if (drc3.Success)\r
- {\r
- string[] drcPoint = drc3.ToString().Split(',');\r
- float.TryParse(drcPoint[2], out drcValue);\r
- thisQuery.DRC3 = drcValue;\r
- }\r
+ if (trackDRCvalues != null)\r
+ if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values\r
+ track.DRC = trackDRCvalues[x].Trim();\r
\r
- thisQuery.DRC4 = 1;\r
- if (drc4.Success)\r
- {\r
- string[] drcPoint = drc4.ToString().Split(',');\r
- float.TryParse(drcPoint[3], out drcValue);\r
- thisQuery.DRC4 = drcValue;\r
+ allAudioTrackInfo.Add(track);\r
}\r
+ thisQuery.AudioInformation = allAudioTrackInfo;\r
\r
// Subtitle Stuff\r
if (subtitles.Success)\r
- thisQuery.Subtitles = subtitles.ToString().Replace("-s ", "");\r
+ thisQuery.Subtitles = subtitles.ToString().Replace("-s ", string.Empty);\r
else\r
thisQuery.Subtitles = subScan.Success ? "Autoselect" : "None";\r
\r
#endregion\r
\r
#region Chapters Tab\r
+\r
if (chapterMarkersFileMode.Success || chapterMarkers.Success)\r
thisQuery.ChapterMarkers = true;\r
+\r
#endregion\r
\r
#region H.264 and other\r
\r
if (x264.Success)\r
- thisQuery.H264Query = x264.ToString().Replace("-x ", "");\r
+ thisQuery.H264Query = x264.ToString().Replace("-x ", string.Empty);\r
\r
thisQuery.Verbose = verbose.Success;\r
\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show(\r
- "An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" +\r
- exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
+ exceptionWindow.Setup("An error has occured in the Query Parser.", exc.ToString());\r
+ exceptionWindow.ShowDialog();\r
}\r
\r
#endregion\r
return thisQuery;\r
}\r
\r
- private static string getMixDown(string mixdown)\r
+ /// <summary>\r
+ /// Get the GUI equiv to a CLI mixdown\r
+ /// </summary>\r
+ /// <param name="mixdown">The Audio Mixdown</param>\r
+ /// <returns>The GUI representation of the mixdown</returns>\r
+ private static string GetMixDown(string mixdown)\r
{\r
switch (mixdown.Trim())\r
{\r
return "Automatic";\r
}\r
}\r
- private static string getAudioEncoder(string audioEnc)\r
+\r
+ /// <summary>\r
+ /// Get the GUI equiv to a CLI audio encoder\r
+ /// </summary>\r
+ /// <param name="audioEnc">The Audio Encoder</param>\r
+ /// <returns>The GUI representation of that audio encoder</returns>\r
+ private static string GetAudioEncoder(string audioEnc)\r
{\r
switch (audioEnc)\r
{\r
case "faac":\r
- return "AAC";\r
+ return "AAC (faac)";\r
case "lame":\r
- return "MP3";\r
+ return "MP3 (lame)";\r
case "vorbis":\r
- return "Vorbis";\r
+ return "Vorbis (vorbis)";\r
case "ac3":\r
- return "AC3";\r
+ return "AC3 Passthru";\r
+ case "dts":\r
+ return "DTS Passthru";\r
default:\r
- return "AAC";\r
+ return "AAC (faac)";\r
}\r
}\r
}\r