{\r
class Common\r
{\r
- #region Presets\r
-\r
- /// <summary>\r
- /// Update the presets.dat file with the latest version of HandBrak's presets from the CLI\r
- /// </summary>\r
- public void grabCLIPresets()\r
- {\r
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
- string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");\r
-\r
- string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
-\r
- ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
- hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
-\r
- Process hbproc = Process.Start(hbGetPresets);\r
- hbproc.WaitForExit();\r
- hbproc.Dispose();\r
- hbproc.Close();\r
- }\r
\r
/// <summary>\r
/// This function takes in a Query which has been parsed by QueryParser and\r
mainWindow.text_height.Text = "";\r
}\r
\r
- #endregion\r
+ #endregion\r
\r
// Video Settings Tab\r
#region video\r
#endregion\r
}\r
\r
- #endregion\r
-\r
- #region Query Generator Functions\r
-\r
- /// <summary>\r
- /// Generates a CLI query based on the GUI widgets.\r
- /// </summary>\r
- /// <param name="mainWindow"></param>\r
- /// <returns>The CLI String</returns>\r
- public string GenerateTheQuery(frmMain mainWindow)\r
- {\r
- // Source tab\r
- #region source\r
- string query = "";\r
-\r
- if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))\r
- query = " -i " + '"' + mainWindow.text_source.Text + '"';\r
-\r
- if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
- {\r
- string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
- query += " -t " + titleInfo[0];\r
- }\r
-\r
- if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto")\r
- query += " -c " + mainWindow.drop_chapterStart.Text;\r
- else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
- query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;\r
- else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
- query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;\r
-\r
- #endregion\r
-\r
- // Destination tab\r
- #region Destination\r
- if (mainWindow.text_destination.Text != "")\r
- query += " -o " + '"' + mainWindow.text_destination.Text + '"';\r
- #endregion\r
-\r
- query += generateTabbedComponentsQuery(mainWindow);\r
- return query;\r
- }\r
-\r
- /// <summary>\r
- /// Generates a CLI query for the preview function.\r
- /// This basically forces a shortened version of the encdode.\r
- /// </summary>\r
- /// <param name="mainWindow"></param>\r
- /// <returns>Returns a CLI query String.</returns>\r
- public string GeneratePreviewQuery(frmMain mainWindow)\r
- {\r
- // Source tab\r
- #region source\r
- string query = "";\r
-\r
- if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))\r
- query = " -i " + '"' + mainWindow.text_source.Text + '"';\r
-\r
- if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
- {\r
- string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
- query += " -t " + titleInfo[0];\r
- }\r
-\r
- query += " -c 2";\r
- #endregion\r
-\r
- // Destination tab\r
- #region Destination\r
- if (mainWindow.text_destination.Text != "")\r
- query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm") + '"';\r
-\r
- #endregion\r
-\r
- query += generateTabbedComponentsQuery(mainWindow);\r
- return query;\r
- }\r
-\r
- /// <summary>\r
- /// Generates part of the CLI query, for the tabbed components only.\r
- /// </summary>\r
- /// <param name="mainWindow"></param>\r
- /// <param name="source"></param>\r
- /// <returns></returns>\r
- public string generateTabbedComponentsQuery(frmMain mainWindow)\r
- {\r
- string query = "";\r
-\r
- // The Output Settings box above the tabbed section.\r
- #region Output Settings Box\r
- query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", "");\r
-\r
- // These are output settings features\r
- if (mainWindow.check_largeFile.Checked)\r
- query += " -4 ";\r
-\r
- if (mainWindow.check_iPodAtom.Checked)\r
- query += " -I ";\r
-\r
- if (mainWindow.check_optimiseMP4.Checked)\r
- query += " -O ";\r
- #endregion\r
-\r
- // Picture Settings Tab\r
- #region Picture Settings Tab\r
-\r
- if (mainWindow.text_width.Text != "")\r
- query += " -w " + mainWindow.text_width.Text;\r
-\r
- if (mainWindow.text_height.Text != "")\r
- query += " -l " + mainWindow.text_height.Text;\r
-\r
- string cropTop = mainWindow.text_top.Text;\r
- string cropBottom = mainWindow.text_bottom.Text;\r
- string cropLeft = mainWindow.text_left.Text;\r
- string cropRight = mainWindow.text_right.Text;\r
-\r
- if (mainWindow.check_customCrop.Checked)\r
- {\r
- if (mainWindow.text_top.Text == string.Empty)\r
- cropTop = "0";\r
- if (mainWindow.text_bottom.Text == string.Empty)\r
- cropBottom = "0";\r
- if (mainWindow.text_left.Text == string.Empty)\r
- cropLeft = "0";\r
- if (mainWindow.text_right.Text == string.Empty)\r
- cropRight = "0";\r
-\r
- query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
- }\r
-\r
- switch (mainWindow.drp_deInterlace_option.Text)\r
- {\r
- case "None":\r
- query += "";\r
- break;\r
- case "Fast":\r
- query += " --deinterlace=\"fast\"";\r
- break;\r
- case "Slow":\r
- query += " --deinterlace=\"slow\"";\r
- break;\r
- case "Slower":\r
- query += " --deinterlace=\"slower\"";\r
- break;\r
- case "Slowest":\r
- query += " --deinterlace=\"slowest\"";\r
- break;\r
- default:\r
- query += "";\r
- break;\r
- }\r
-\r
- if (mainWindow.check_decomb.Checked)\r
- {\r
- string decombValue = Properties.Settings.Default.decomb;\r
- if (decombValue != "" && decombValue != Properties.Settings.Default.default_decomb)\r
- query += " --decomb=\"" + decombValue + "\"";\r
- else\r
- query += " --decomb ";\r
- }\r
-\r
- if (mainWindow.drp_anamorphic.SelectedIndex == 1)\r
- query += " -p ";\r
- else if (mainWindow.drp_anamorphic.SelectedIndex == 2)\r
- query += " -P ";\r
-\r
- if (mainWindow.slider_deblock.Value != 4)\r
- query += " --deblock=" + mainWindow.slider_deblock.Value;\r
-\r
- if (mainWindow.check_detelecine.Checked)\r
- query += " --detelecine";\r
- #endregion\r
-\r
- // Video Settings Tab\r
- #region Video Settings Tab\r
-\r
- switch (mainWindow.drp_videoEncoder.Text)\r
- {\r
- case "MPEG-4 (FFmpeg)":\r
- query += " -e ffmpeg";\r
- break;\r
- case "MPEG-4 (XviD)":\r
- query += " -e xvid";\r
- break;\r
- case "H.264 (x264)":\r
- query += " -e x264";\r
- break;\r
- case "VP3 (Theora)":\r
- query += " -e theora";\r
- break;\r
- default:\r
- query += " -e x264";\r
- break;\r
- }\r
-\r
- if (mainWindow.check_grayscale.Checked)\r
- query += " -g ";\r
-\r
- // Video Settings\r
- if (mainWindow.text_bitrate.Text != "")\r
- query += " -b " + mainWindow.text_bitrate.Text;\r
-\r
- if (mainWindow.text_filesize.Text != "")\r
- query += " -S " + mainWindow.text_filesize.Text;\r
-\r
- // Video Quality Setting\r
- double videoQuality = mainWindow.slider_videoQuality.Value;\r
- if (videoQuality != 0)\r
- {\r
- videoQuality = videoQuality / 100;\r
- query += " -q " + videoQuality.ToString(new CultureInfo("en-US"));\r
- }\r
-\r
- if (mainWindow.check_2PassEncode.Checked)\r
- query += " -2 ";\r
-\r
- if (mainWindow.check_turbo.Checked)\r
- query += " -T ";\r
-\r
- if (mainWindow.drp_videoFramerate.Text != "Same as source")\r
- query += " -r " + mainWindow.drp_videoFramerate.Text;\r
-\r
- switch (mainWindow.drp_deNoise.Text)\r
- {\r
- case "None":\r
- query += "";\r
- break;\r
- case "Weak":\r
- query += " --denoise=\"weak\"";\r
- break;\r
- case "Medium":\r
- query += " --denoise=\"medium\"";\r
- break;\r
- case "Strong":\r
- query += " --denoise=\"strong\"";\r
- break;\r
- default:\r
- query += "";\r
- break;\r
- }\r
- #endregion\r
-\r
- // Audio Settings Tab\r
- #region Audio Settings Tab\r
- // Track 1\r
- string track1 = mainWindow.drp_track1Audio.Text;\r
- string aencoder1 = mainWindow.drp_audenc_1.Text;\r
- string audioBitrate1 = mainWindow.drp_audbit_1.Text;\r
- string audioSampleRate1 = mainWindow.drp_audsr_1.Text;\r
- string Mixdown1 = mainWindow.drp_audmix_1.Text;\r
- string drc1 = mainWindow.trackBar1.Value.ToString();\r
-\r
- // Track 2\r
- string track2 = mainWindow.drp_track2Audio.Text;\r
- string aencoder2 = mainWindow.drp_audenc_2.Text;\r
- string audioBitrate2 = mainWindow.drp_audbit_2.Text;\r
- string audioSampleRate2 = mainWindow.drp_audsr_2.Text;\r
- string Mixdown2 = mainWindow.drp_audmix_2.Text;\r
- string drc2 = mainWindow.trackBar2.Value.ToString();\r
-\r
- // Track 3\r
- string track3 = mainWindow.drp_track3Audio.Text;\r
- string aencoder3 = mainWindow.drp_audenc_3.Text;\r
- string audioBitrate3 = mainWindow.drp_audbit_3.Text;\r
- string audioSampleRate3 = mainWindow.drp_audsr_3.Text;\r
- string Mixdown3 = mainWindow.drp_audmix_3.Text;\r
- string drc3 = mainWindow.trackBar3.Value.ToString();\r
-\r
- // Track 4\r
- string track4 = mainWindow.drp_track4Audio.Text;\r
- string aencoder4 = mainWindow.drp_audenc_4.Text;\r
- string audioBitrate4 = mainWindow.drp_audbit_4.Text;\r
- string audioSampleRate4 = mainWindow.drp_audsr_4.Text;\r
- string Mixdown4 = mainWindow.drp_audmix_4.Text;\r
- string drc4 = mainWindow.trackBar4.Value.ToString();\r
-\r
- //\r
- // Audio Track Selections\r
- //\r
- if (track1 == "Automatic")\r
- query += " -a 1";\r
- else if (track1 != "None")\r
- {\r
- string[] tempSub = track1.Split(' ');\r
- query += " -a " + tempSub[0];\r
- }\r
-\r
- if (track2 == "Automatic")\r
- query += ",1";\r
- else if (track2 != "None")\r
- {\r
- string[] tempSub;\r
- tempSub = track2.Split(' ');\r
-\r
- if (track1 == "None")\r
- query += " -a none," + tempSub[0];\r
- else\r
- query += "," + tempSub[0];\r
- }\r
-\r
- if (track3 != "None")\r
- {\r
- string[] tempSub;\r
- tempSub = track3.Split(' ');\r
- query += "," + tempSub[0];\r
- }\r
-\r
- if (track4 != "None")\r
- {\r
- string[] tempSub;\r
- tempSub = track4.Split(' ');\r
- query += "," + tempSub[0];\r
- }\r
-\r
- //\r
- // Audio Encoder\r
- //\r
- if (aencoder1 != "")\r
- query += " -E " + getAudioEncoder(aencoder1);\r
-\r
- if (aencoder2 != "")\r
- {\r
- if (aencoder1 == string.Empty)\r
- query += " -E faac," + getAudioEncoder(aencoder2);\r
- else\r
- query += "," + getAudioEncoder(aencoder2);\r
- }\r
-\r
- if (aencoder3 != "")\r
- query += "," + getAudioEncoder(aencoder3);\r
-\r
- if (aencoder4 != "")\r
- query += "," + getAudioEncoder(aencoder4);\r
-\r
- //\r
- // Audio Bitrate Selections\r
- //\r
- if (audioBitrate1 != "")\r
- query += " -B " + audioBitrate1;\r
-\r
- if (audioBitrate2 != "")\r
- {\r
- if (audioBitrate1 == string.Empty)\r
- query += " -B 160," + audioBitrate2;\r
- else\r
- query += "," + audioBitrate2;\r
- }\r
-\r
- if (audioBitrate3 != "")\r
- query += "," + audioBitrate3;\r
-\r
- if (audioBitrate4 != "")\r
- query += "," + audioBitrate4;\r
-\r
-\r
- //Audio Sample Rate - audioSampleRate\r
- if (audioSampleRate1 != "")\r
- query += " -R " + audioSampleRate1.Replace("Auto", "0");\r
-\r
- if (audioSampleRate2 != "")\r
- {\r
- if (audioSampleRate1 == string.Empty)\r
- query += " -R 0," + audioSampleRate2.Replace("Auto", "0");\r
- else\r
- query += "," + audioSampleRate2.Replace("Auto", "0");\r
- }\r
- else\r
- {\r
- // All this is a hack, because when AppleTV is selected, there is no sample rate selected. so just add a 48\r
- // It should probably be setup later so the GUI widget has the value 48 in it.\r
-\r
- if ((track2 != "") && (track2 != "None"))\r
- {\r
- if (audioSampleRate1 == string.Empty)\r
- query += " -R 0,0";\r
- else\r
- query += ",0";\r
- }\r
- }\r
-\r
- if (audioSampleRate3 != "")\r
- query += "," + audioSampleRate3.Replace("Auto", "0");\r
-\r
- if (audioSampleRate4 != "")\r
- query += "," + audioSampleRate4.Replace("Auto", "0");\r
-\r
- //\r
- // Audio Mixdown Selections\r
- //\r
-\r
- if (Mixdown1 != "")\r
- query += " -6 " + getMixDown(Mixdown1);\r
- else\r
- query += " -6 dpl2";\r
-\r
- if (Mixdown2 != "" && track2 != "None")\r
- query += "," + getMixDown(Mixdown2);\r
-\r
- if (Mixdown3 != "" && track3 != "None" && track2 != "None")\r
- query += "," + getMixDown(Mixdown3);\r
-\r
- if (Mixdown4 != "" && track4 != "None" && track3 != "None")\r
- query += "," + getMixDown(Mixdown4);\r
-\r
-\r
- //\r
- // DRC\r
- //\r
- double value = 0;\r
-\r
- value = mainWindow.trackBar1.Value / 10.0;\r
- value++;\r
-\r
- if (value > 1.0)\r
- query += " -D " + value;\r
- else\r
- query += " -D 1";\r
-\r
- value = mainWindow.trackBar2.Value / 10.0;\r
- value++;\r
- if (track2 != "None" && drc2 != "0")\r
- query += "," + value;\r
- else if (track2 != "None" && drc2 == "0")\r
- query += ",1";\r
-\r
- value = mainWindow.trackBar3.Value / 10.0;\r
- value++;\r
- if (track3 != "None" && drc3 != "0")\r
- query += "," + value;\r
- else if (track3 != "None" && drc3 == "0")\r
- query += ",1";\r
-\r
- value = mainWindow.trackBar4.Value / 10.0;\r
- value++;\r
- if (track4 != "None" && drc4 != "0")\r
- query += "," + value;\r
- else if (track4 != "None" && drc4 == "0")\r
- query += ",1";\r
-\r
- // Subtitles\r
- string subtitles = mainWindow.drp_subtitle.Text;\r
- if (subtitles == "Autoselect")\r
- query += " -U ";\r
- else if (subtitles != "" && subtitles != "None")\r
- {\r
- string[] tempSub;\r
- tempSub = subtitles.Split(' ');\r
- query += " -s " + tempSub[0];\r
- }\r
-\r
- if (mainWindow.check_forced.Checked)\r
- query += " -F ";\r
-\r
- #endregion\r
-\r
- // Chapter Markers Tab\r
- #region Chapter Markers\r
-\r
- // Attach Source name and dvd title to the start of the chapters.csv filename.\r
- // This is for the queue. It allows different chapter name files for each title.\r
- string source_name = mainWindow.text_source.Text;\r
- string[] sourceName = source_name.Split('\\');\r
- source_name = sourceName[sourceName.Length - 1];\r
- source_name = source_name.Replace("\"", "");\r
-\r
- string source_title = mainWindow.drp_dvdtitle.Text;\r
- string[] titlesplit = source_title.Split(' ');\r
- source_title = titlesplit[0];\r
-\r
- if (mainWindow.Check_ChapterMarkers.Checked)\r
- {\r
- if ((source_name.Trim() != "Click 'Source' to continue") && (source_name.Trim() != ""))\r
- {\r
- string path = "";\r
- if (source_title != "Automatic")\r
- path = Path.Combine(Path.GetTempPath(), source_name + "-" + source_title + "-chapters.csv");\r
- else\r
- path = Path.Combine(Path.GetTempPath(), source_name + "-chapters.csv");\r
-\r
- if (chapterCSVSave(mainWindow, path) == false)\r
- query += " -m ";\r
- else\r
- query += " --markers=" + "\"" + path + "\"";\r
- }\r
- else\r
- query += " -m";\r
- }\r
- #endregion\r
-\r
- // H264 Tab\r
- #region H264 Tab\r
- if (mainWindow.rtf_x264Query.Text != "")\r
- query += " -x " + mainWindow.rtf_x264Query.Text;\r
- #endregion\r
-\r
- // Other\r
- #region Processors / Other\r
- string processors = Properties.Settings.Default.Processors;\r
- if (processors != "Automatic")\r
- query += " -C " + processors + " ";\r
-\r
- query += " -v ";\r
- #endregion\r
-\r
- return query;\r
- }\r
-\r
- /// <summary>\r
- /// Get the CLI equive of the audio mixdown from the widget name.\r
- /// </summary>\r
- /// <param name="selectedAudio"></param>\r
- /// <returns></returns>\r
- /// \r
- private string getMixDown(string selectedAudio)\r
- {\r
- switch (selectedAudio)\r
- {\r
- case "Automatic":\r
- return "dpl2";\r
- case "Mono":\r
- return "mono";\r
- case "Stereo":\r
- return "stereo";\r
- case "Dolby Surround":\r
- return "dpl1";\r
- case "Dolby Pro Logic II":\r
- return "dpl2";\r
- case "6 Channel Discrete":\r
- return "6ch";\r
- default:\r
- return "dpl2";\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Get the CLI equiv of the audio encoder from the widget name.\r
- /// </summary>\r
- /// <param name="selectedEncoder"></param>\r
- /// <returns></returns>\r
- /// \r
- private string getAudioEncoder(string selectedEncoder)\r
- {\r
- switch (selectedEncoder)\r
- {\r
- case "AAC":\r
- return "faac";\r
- case "MP3":\r
- return "lame";\r
- case "Vorbis":\r
- return "vorbis";\r
- case "AC3":\r
- return "ac3";\r
- default:\r
- return "";\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv\r
- /// in a directory specified by file_path_name\r
- /// </summary>\r
- /// <param name="mainWindow"></param>\r
- /// <param name="file_path_name"></param>\r
- /// <returns></returns>\r
- private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)\r
- {\r
- try\r
- {\r
- StringBuilder csv = new StringBuilder();\r
-\r
- foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)\r
- {\r
- csv.Append(row.Cells[0].Value.ToString());\r
- csv.Append(",");\r
- csv.Append(row.Cells[1].Value.ToString());\r
- csv.Append(Environment.NewLine);\r
- }\r
- StreamWriter file = new StreamWriter(file_path_name);\r
- file.Write(csv.ToString());\r
- file.Close();\r
- file.Dispose();\r
- return true;\r
-\r
- }\r
- catch (Exception exc)\r
- {\r
- MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- return false;\r
- }\r
- }\r
-\r
- #endregion\r
-\r
- #region Actions, Versioning etc\r
-\r
/// <summary>\r
/// Select the longest title in the DVD title dropdown menu on frmMain\r
/// </summary>\r
}\r
}\r
\r
- #endregion\r
-\r
}\r
}
\ No newline at end of file
using System.Windows.Forms;\r
using System.IO;\r
using System.Text.RegularExpressions;\r
-\r
+using System.Diagnostics;\r
\r
namespace Handbrake.Functions\r
{\r
return null;\r
}\r
\r
+ /// <summary>\r
+ /// Update the presets.dat file with the latest version of HandBrake's presets from the CLI\r
+ /// </summary>\r
+ public void grabCLIPresets()\r
+ {\r
+ string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
+ string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");\r
+\r
+ string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
+\r
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
+ hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
+\r
+ Process hbproc = Process.Start(hbGetPresets);\r
+ hbproc.WaitForExit();\r
+ hbproc.Dispose();\r
+ hbproc.Close();\r
+ }\r
+\r
/// <summary>\r
/// Load in the preset data from presets.dat and user_presets.dat\r
/// Load it into the 2 arraylist's presets and user_presets\r
--- /dev/null
+using System;\r
+using System.Collections;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+using System.Globalization;\r
+using System.IO;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+ class QueryGenerator\r
+ {\r
+ /// <summary>\r
+ /// Generates a CLI query based on the GUI widgets.\r
+ /// </summary>\r
+ /// <param name="mainWindow"></param>\r
+ /// <returns>The CLI String</returns>\r
+ public string GenerateTheQuery(frmMain mainWindow)\r
+ {\r
+ // Source tab\r
+ string query = "";\r
+\r
+ if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))\r
+ query = " -i " + '"' + mainWindow.text_source.Text + '"';\r
+\r
+ if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
+ {\r
+ string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
+ query += " -t " + titleInfo[0];\r
+ }\r
+\r
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto")\r
+ query += " -c " + mainWindow.drop_chapterStart.Text;\r
+ else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
+ query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;\r
+ else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
+ query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;\r
+\r
+ // Destination tab\r
+ if (mainWindow.text_destination.Text != "")\r
+ query += " -o " + '"' + mainWindow.text_destination.Text + '"';\r
+\r
+ query += generateTabbedComponentsQuery(mainWindow);\r
+ return query;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Generates a CLI query for the preview function.\r
+ /// This basically forces a shortened version of the encdode.\r
+ /// </summary>\r
+ /// <param name="mainWindow"></param>\r
+ /// <returns>Returns a CLI query String.</returns>\r
+ public string GeneratePreviewQuery(frmMain mainWindow)\r
+ {\r
+ // Source tab\r
+ string query = "";\r
+\r
+ if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))\r
+ query = " -i " + '"' + mainWindow.text_source.Text + '"';\r
+\r
+ if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
+ {\r
+ string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
+ query += " -t " + titleInfo[0];\r
+ }\r
+\r
+ query += " -c 2";\r
+\r
+ // Destination tab\r
+ if (mainWindow.text_destination.Text != "")\r
+ query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm") + '"';\r
+\r
+ query += generateTabbedComponentsQuery(mainWindow);\r
+ return query;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Generates part of the CLI query, for the tabbed components only.\r
+ /// </summary>\r
+ /// <param name="mainWindow"></param>\r
+ /// <param name="source"></param>\r
+ /// <returns></returns>\r
+ public string generateTabbedComponentsQuery(frmMain mainWindow)\r
+ {\r
+ string query = "";\r
+\r
+ // The Output Settings box above the tabbed section.\r
+ #region Output Settings Box\r
+ query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", "");\r
+\r
+ // These are output settings features\r
+ if (mainWindow.check_largeFile.Checked)\r
+ query += " -4 ";\r
+\r
+ if (mainWindow.check_iPodAtom.Checked)\r
+ query += " -I ";\r
+\r
+ if (mainWindow.check_optimiseMP4.Checked)\r
+ query += " -O ";\r
+ #endregion\r
+\r
+ // Picture Settings Tab\r
+ #region Picture Settings Tab\r
+\r
+ if (mainWindow.text_width.Text != "")\r
+ query += " -w " + mainWindow.text_width.Text;\r
+\r
+ if (mainWindow.text_height.Text != "")\r
+ query += " -l " + mainWindow.text_height.Text;\r
+\r
+ string cropTop = mainWindow.text_top.Text;\r
+ string cropBottom = mainWindow.text_bottom.Text;\r
+ string cropLeft = mainWindow.text_left.Text;\r
+ string cropRight = mainWindow.text_right.Text;\r
+\r
+ if (mainWindow.check_customCrop.Checked)\r
+ {\r
+ if (mainWindow.text_top.Text == string.Empty)\r
+ cropTop = "0";\r
+ if (mainWindow.text_bottom.Text == string.Empty)\r
+ cropBottom = "0";\r
+ if (mainWindow.text_left.Text == string.Empty)\r
+ cropLeft = "0";\r
+ if (mainWindow.text_right.Text == string.Empty)\r
+ cropRight = "0";\r
+\r
+ query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
+ }\r
+\r
+ switch (mainWindow.drp_deInterlace_option.Text)\r
+ {\r
+ case "None":\r
+ query += "";\r
+ break;\r
+ case "Fast":\r
+ query += " --deinterlace=\"fast\"";\r
+ break;\r
+ case "Slow":\r
+ query += " --deinterlace=\"slow\"";\r
+ break;\r
+ case "Slower":\r
+ query += " --deinterlace=\"slower\"";\r
+ break;\r
+ case "Slowest":\r
+ query += " --deinterlace=\"slowest\"";\r
+ break;\r
+ default:\r
+ query += "";\r
+ break;\r
+ }\r
+\r
+ if (mainWindow.check_decomb.Checked)\r
+ {\r
+ string decombValue = Properties.Settings.Default.decomb;\r
+ if (decombValue != "" && decombValue != Properties.Settings.Default.default_decomb)\r
+ query += " --decomb=\"" + decombValue + "\"";\r
+ else\r
+ query += " --decomb ";\r
+ }\r
+\r
+ if (mainWindow.drp_anamorphic.SelectedIndex == 1)\r
+ query += " -p ";\r
+ else if (mainWindow.drp_anamorphic.SelectedIndex == 2)\r
+ query += " -P ";\r
+\r
+ if (mainWindow.slider_deblock.Value != 4)\r
+ query += " --deblock=" + mainWindow.slider_deblock.Value;\r
+\r
+ if (mainWindow.check_detelecine.Checked)\r
+ query += " --detelecine";\r
+ #endregion\r
+\r
+ // Video Settings Tab\r
+ #region Video Settings Tab\r
+\r
+ switch (mainWindow.drp_videoEncoder.Text)\r
+ {\r
+ case "MPEG-4 (FFmpeg)":\r
+ query += " -e ffmpeg";\r
+ break;\r
+ case "MPEG-4 (XviD)":\r
+ query += " -e xvid";\r
+ break;\r
+ case "H.264 (x264)":\r
+ query += " -e x264";\r
+ break;\r
+ case "VP3 (Theora)":\r
+ query += " -e theora";\r
+ break;\r
+ default:\r
+ query += " -e x264";\r
+ break;\r
+ }\r
+\r
+ if (mainWindow.check_grayscale.Checked)\r
+ query += " -g ";\r
+\r
+ // Video Settings\r
+ if (mainWindow.text_bitrate.Text != "")\r
+ query += " -b " + mainWindow.text_bitrate.Text;\r
+\r
+ if (mainWindow.text_filesize.Text != "")\r
+ query += " -S " + mainWindow.text_filesize.Text;\r
+\r
+ // Video Quality Setting\r
+ double videoQuality = mainWindow.slider_videoQuality.Value;\r
+ if (videoQuality != 0)\r
+ {\r
+ videoQuality = videoQuality / 100;\r
+ query += " -q " + videoQuality.ToString(new CultureInfo("en-US"));\r
+ }\r
+\r
+ if (mainWindow.check_2PassEncode.Checked)\r
+ query += " -2 ";\r
+\r
+ if (mainWindow.check_turbo.Checked)\r
+ query += " -T ";\r
+\r
+ if (mainWindow.drp_videoFramerate.Text != "Same as source")\r
+ query += " -r " + mainWindow.drp_videoFramerate.Text;\r
+\r
+ switch (mainWindow.drp_deNoise.Text)\r
+ {\r
+ case "None":\r
+ query += "";\r
+ break;\r
+ case "Weak":\r
+ query += " --denoise=\"weak\"";\r
+ break;\r
+ case "Medium":\r
+ query += " --denoise=\"medium\"";\r
+ break;\r
+ case "Strong":\r
+ query += " --denoise=\"strong\"";\r
+ break;\r
+ default:\r
+ query += "";\r
+ break;\r
+ }\r
+ #endregion\r
+\r
+ // Audio Settings Tab\r
+ #region Audio Settings Tab\r
+ // Track 1\r
+ string track1 = mainWindow.drp_track1Audio.Text;\r
+ string aencoder1 = mainWindow.drp_audenc_1.Text;\r
+ string audioBitrate1 = mainWindow.drp_audbit_1.Text;\r
+ string audioSampleRate1 = mainWindow.drp_audsr_1.Text;\r
+ string Mixdown1 = mainWindow.drp_audmix_1.Text;\r
+ string drc1 = mainWindow.trackBar1.Value.ToString();\r
+\r
+ // Track 2\r
+ string track2 = mainWindow.drp_track2Audio.Text;\r
+ string aencoder2 = mainWindow.drp_audenc_2.Text;\r
+ string audioBitrate2 = mainWindow.drp_audbit_2.Text;\r
+ string audioSampleRate2 = mainWindow.drp_audsr_2.Text;\r
+ string Mixdown2 = mainWindow.drp_audmix_2.Text;\r
+ string drc2 = mainWindow.trackBar2.Value.ToString();\r
+\r
+ // Track 3\r
+ string track3 = mainWindow.drp_track3Audio.Text;\r
+ string aencoder3 = mainWindow.drp_audenc_3.Text;\r
+ string audioBitrate3 = mainWindow.drp_audbit_3.Text;\r
+ string audioSampleRate3 = mainWindow.drp_audsr_3.Text;\r
+ string Mixdown3 = mainWindow.drp_audmix_3.Text;\r
+ string drc3 = mainWindow.trackBar3.Value.ToString();\r
+\r
+ // Track 4\r
+ string track4 = mainWindow.drp_track4Audio.Text;\r
+ string aencoder4 = mainWindow.drp_audenc_4.Text;\r
+ string audioBitrate4 = mainWindow.drp_audbit_4.Text;\r
+ string audioSampleRate4 = mainWindow.drp_audsr_4.Text;\r
+ string Mixdown4 = mainWindow.drp_audmix_4.Text;\r
+ string drc4 = mainWindow.trackBar4.Value.ToString();\r
+\r
+ //\r
+ // Audio Track Selections\r
+ //\r
+ if (track1 == "Automatic")\r
+ query += " -a 1";\r
+ else if (track1 != "None")\r
+ {\r
+ string[] tempSub = track1.Split(' ');\r
+ query += " -a " + tempSub[0];\r
+ }\r
+\r
+ if (track2 == "Automatic")\r
+ query += ",1";\r
+ else if (track2 != "None")\r
+ {\r
+ string[] tempSub;\r
+ tempSub = track2.Split(' ');\r
+\r
+ if (track1 == "None")\r
+ query += " -a none," + tempSub[0];\r
+ else\r
+ query += "," + tempSub[0];\r
+ }\r
+\r
+ if (track3 != "None")\r
+ {\r
+ string[] tempSub;\r
+ tempSub = track3.Split(' ');\r
+ query += "," + tempSub[0];\r
+ }\r
+\r
+ if (track4 != "None")\r
+ {\r
+ string[] tempSub;\r
+ tempSub = track4.Split(' ');\r
+ query += "," + tempSub[0];\r
+ }\r
+\r
+ //\r
+ // Audio Encoder\r
+ //\r
+ if (aencoder1 != "")\r
+ query += " -E " + getAudioEncoder(aencoder1);\r
+\r
+ if (aencoder2 != "")\r
+ {\r
+ if (aencoder1 == string.Empty)\r
+ query += " -E faac," + getAudioEncoder(aencoder2);\r
+ else\r
+ query += "," + getAudioEncoder(aencoder2);\r
+ }\r
+\r
+ if (aencoder3 != "")\r
+ query += "," + getAudioEncoder(aencoder3);\r
+\r
+ if (aencoder4 != "")\r
+ query += "," + getAudioEncoder(aencoder4);\r
+\r
+ //\r
+ // Audio Bitrate Selections\r
+ //\r
+ if (audioBitrate1 != "")\r
+ query += " -B " + audioBitrate1;\r
+\r
+ if (audioBitrate2 != "")\r
+ {\r
+ if (audioBitrate1 == string.Empty)\r
+ query += " -B 160," + audioBitrate2;\r
+ else\r
+ query += "," + audioBitrate2;\r
+ }\r
+\r
+ if (audioBitrate3 != "")\r
+ query += "," + audioBitrate3;\r
+\r
+ if (audioBitrate4 != "")\r
+ query += "," + audioBitrate4;\r
+\r
+\r
+ //Audio Sample Rate - audioSampleRate\r
+ if (audioSampleRate1 != "")\r
+ query += " -R " + audioSampleRate1.Replace("Auto", "0");\r
+\r
+ if (audioSampleRate2 != "")\r
+ {\r
+ if (audioSampleRate1 == string.Empty)\r
+ query += " -R 0," + audioSampleRate2.Replace("Auto", "0");\r
+ else\r
+ query += "," + audioSampleRate2.Replace("Auto", "0");\r
+ }\r
+ else\r
+ {\r
+ // All this is a hack, because when AppleTV is selected, there is no sample rate selected. so just add a 48\r
+ // It should probably be setup later so the GUI widget has the value 48 in it.\r
+\r
+ if ((track2 != "") && (track2 != "None"))\r
+ {\r
+ if (audioSampleRate1 == string.Empty)\r
+ query += " -R 0,0";\r
+ else\r
+ query += ",0";\r
+ }\r
+ }\r
+\r
+ if (audioSampleRate3 != "")\r
+ query += "," + audioSampleRate3.Replace("Auto", "0");\r
+\r
+ if (audioSampleRate4 != "")\r
+ query += "," + audioSampleRate4.Replace("Auto", "0");\r
+\r
+ //\r
+ // Audio Mixdown Selections\r
+ //\r
+\r
+ if (Mixdown1 != "")\r
+ query += " -6 " + getMixDown(Mixdown1);\r
+ else\r
+ query += " -6 dpl2";\r
+\r
+ if (Mixdown2 != "" && track2 != "None")\r
+ query += "," + getMixDown(Mixdown2);\r
+\r
+ if (Mixdown3 != "" && track3 != "None" && track2 != "None")\r
+ query += "," + getMixDown(Mixdown3);\r
+\r
+ if (Mixdown4 != "" && track4 != "None" && track3 != "None")\r
+ query += "," + getMixDown(Mixdown4);\r
+\r
+\r
+ //\r
+ // DRC\r
+ //\r
+ double value = 0;\r
+\r
+ value = mainWindow.trackBar1.Value / 10.0;\r
+ value++;\r
+\r
+ if (value > 1.0)\r
+ query += " -D " + value;\r
+ else\r
+ query += " -D 1";\r
+\r
+ value = mainWindow.trackBar2.Value / 10.0;\r
+ value++;\r
+ if (track2 != "None" && drc2 != "0")\r
+ query += "," + value;\r
+ else if (track2 != "None" && drc2 == "0")\r
+ query += ",1";\r
+\r
+ value = mainWindow.trackBar3.Value / 10.0;\r
+ value++;\r
+ if (track3 != "None" && drc3 != "0")\r
+ query += "," + value;\r
+ else if (track3 != "None" && drc3 == "0")\r
+ query += ",1";\r
+\r
+ value = mainWindow.trackBar4.Value / 10.0;\r
+ value++;\r
+ if (track4 != "None" && drc4 != "0")\r
+ query += "," + value;\r
+ else if (track4 != "None" && drc4 == "0")\r
+ query += ",1";\r
+\r
+ // Subtitles\r
+ string subtitles = mainWindow.drp_subtitle.Text;\r
+ if (subtitles == "Autoselect")\r
+ query += " -U ";\r
+ else if (subtitles != "" && subtitles != "None")\r
+ {\r
+ string[] tempSub;\r
+ tempSub = subtitles.Split(' ');\r
+ query += " -s " + tempSub[0];\r
+ }\r
+\r
+ if (mainWindow.check_forced.Checked)\r
+ query += " -F ";\r
+\r
+ #endregion\r
+\r
+ // Chapter Markers Tab\r
+ #region Chapter Markers\r
+\r
+ // Attach Source name and dvd title to the start of the chapters.csv filename.\r
+ // This is for the queue. It allows different chapter name files for each title.\r
+ string source_name = mainWindow.text_source.Text;\r
+ string[] sourceName = source_name.Split('\\');\r
+ source_name = sourceName[sourceName.Length - 1];\r
+ source_name = source_name.Replace("\"", "");\r
+\r
+ string source_title = mainWindow.drp_dvdtitle.Text;\r
+ string[] titlesplit = source_title.Split(' ');\r
+ source_title = titlesplit[0];\r
+\r
+ if (mainWindow.Check_ChapterMarkers.Checked)\r
+ {\r
+ if ((source_name.Trim() != "Click 'Source' to continue") && (source_name.Trim() != ""))\r
+ {\r
+ string path = "";\r
+ if (source_title != "Automatic")\r
+ path = Path.Combine(Path.GetTempPath(), source_name + "-" + source_title + "-chapters.csv");\r
+ else\r
+ path = Path.Combine(Path.GetTempPath(), source_name + "-chapters.csv");\r
+\r
+ if (chapterCSVSave(mainWindow, path) == false)\r
+ query += " -m ";\r
+ else\r
+ query += " --markers=" + "\"" + path + "\"";\r
+ }\r
+ else\r
+ query += " -m";\r
+ }\r
+ #endregion\r
+\r
+ // H264 Tab\r
+ #region H264 Tab\r
+ if (mainWindow.rtf_x264Query.Text != "")\r
+ query += " -x " + mainWindow.rtf_x264Query.Text;\r
+ #endregion\r
+\r
+ // Other\r
+ #region Processors / Other\r
+ string processors = Properties.Settings.Default.Processors;\r
+ if (processors != "Automatic")\r
+ query += " -C " + processors + " ";\r
+\r
+ query += " -v ";\r
+ #endregion\r
+\r
+ return query;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get the CLI equive of the audio mixdown from the widget name.\r
+ /// </summary>\r
+ /// <param name="selectedAudio"></param>\r
+ /// <returns></returns>\r
+ /// \r
+ private string getMixDown(string selectedAudio)\r
+ {\r
+ switch (selectedAudio)\r
+ {\r
+ case "Automatic":\r
+ return "dpl2";\r
+ case "Mono":\r
+ return "mono";\r
+ case "Stereo":\r
+ return "stereo";\r
+ case "Dolby Surround":\r
+ return "dpl1";\r
+ case "Dolby Pro Logic II":\r
+ return "dpl2";\r
+ case "6 Channel Discrete":\r
+ return "6ch";\r
+ default:\r
+ return "dpl2";\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get the CLI equiv of the audio encoder from the widget name.\r
+ /// </summary>\r
+ /// <param name="selectedEncoder"></param>\r
+ /// <returns></returns>\r
+ /// \r
+ private string getAudioEncoder(string selectedEncoder)\r
+ {\r
+ switch (selectedEncoder)\r
+ {\r
+ case "AAC":\r
+ return "faac";\r
+ case "MP3":\r
+ return "lame";\r
+ case "Vorbis":\r
+ return "vorbis";\r
+ case "AC3":\r
+ return "ac3";\r
+ default:\r
+ return "";\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv\r
+ /// in a directory specified by file_path_name\r
+ /// </summary>\r
+ /// <param name="mainWindow"></param>\r
+ /// <param name="file_path_name"></param>\r
+ /// <returns></returns>\r
+ private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)\r
+ {\r
+ try\r
+ {\r
+ StringBuilder csv = new StringBuilder();\r
+\r
+ foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)\r
+ {\r
+ csv.Append(row.Cells[0].Value.ToString());\r
+ csv.Append(",");\r
+ csv.Append(row.Cells[1].Value.ToString());\r
+ csv.Append(Environment.NewLine);\r
+ }\r
+ StreamWriter file = new StreamWriter(file_path_name);\r
+ file.Write(csv.ToString());\r
+ file.Close();\r
+ file.Dispose();\r
+ return true;\r
+\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+}\r
<Compile Include="frmUpdater.designer.cs">\r
<DependentUpon>frmUpdater.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="Functions\QueryGenerator.cs" />\r
<Compile Include="Functions\SystemInfo.cs" />\r
<Compile Include="Functions\Common.cs" />\r
<Compile Include="Functions\Presets.cs" />\r
{\r
public partial class frmAddPreset : Form\r
{\r
- Functions.Common hb_common_func = new Functions.Common();\r
+ Functions.QueryGenerator queryGen = new Functions.QueryGenerator();\r
private frmMain frmMainWindow;\r
Functions.Presets presetCode;\r
\r
\r
private void btn_add_Click(object sender, EventArgs e)\r
{\r
- String query = hb_common_func.generateTabbedComponentsQuery(frmMainWindow);\r
+ String query = queryGen.generateTabbedComponentsQuery(frmMainWindow);\r
\r
if (presetCode.addPreset(txt_preset_name.Text.Trim(), query) == true)\r
{\r
Functions.Encode cliObj = new Functions.Encode();\r
Functions.Queue encodeQueue = new Functions.Queue();\r
Functions.Presets presetHandler = new Functions.Presets();\r
+ Functions.QueryGenerator queryGen = new Functions.QueryGenerator();\r
Parsing.Title selectedTitle;\r
internal Process hbProc;\r
private Parsing.DVD thisDVD;\r
#region Presets Menu\r
private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
- hb_common_func.grabCLIPresets();\r
+ presetHandler.grabCLIPresets();\r
loadPresetPanel();\r
if (treeView_presets.Nodes.Count == 0)\r
MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
if (rtf_query.Text != "")\r
query = rtf_query.Text;\r
else\r
- query = hb_common_func.GenerateTheQuery(this);\r
+ query = queryGen.GenerateTheQuery(this);\r
\r
ThreadPool.QueueUserWorkItem(procMonitor, query);\r
lbl_encode.Visible = true;\r
else\r
{\r
\r
- String query = hb_common_func.GenerateTheQuery(this);\r
+ String query = queryGen.GenerateTheQuery(this);\r
if (rtf_query.Text != "")\r
query = rtf_query.Text;\r
\r
// Query Editor Tab\r
private void btn_generate_Query_Click(object sender, EventArgs e)\r
{\r
- rtf_query.Text = hb_common_func.GenerateTheQuery(this);\r
+ rtf_query.Text = queryGen.GenerateTheQuery(this);\r
}\r
private void btn_clear_Click(object sender, EventArgs e)\r
{\r
}\r
private void btn_setDefault_Click(object sender, EventArgs e)\r
{\r
- String query = hb_common_func.GenerateTheQuery(this);\r
+ String query = queryGen.GenerateTheQuery(this);\r
Properties.Settings.Default.defaultUserSettings = query;\r
// Save the new default Settings\r
Properties.Settings.Default.Save();\r
btn_start.ToolTipText = "Start the encoding process";\r
btn_start.Image = Properties.Resources.Play;\r
}\r
- \r
\r
#endregion\r
\r
}\r
#endregion\r
\r
- \r
// This is the END of the road ------------------------------------------------------------------------------\r
}\r
}
\ No newline at end of file