summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-12-28 19:47:34 +0000
committersr55 <[email protected]>2009-12-28 19:47:34 +0000
commit15678a6a29c5a4fdd8e9c644fa3727060bfb07de (patch)
tree853f703027cc51403be2b7aafb59c6a4df03e3a6 /win/C#/Functions
parent07ddcfd523083066e7058049ed1017b2cb0ba60b (diff)
WinGui:
- Improve VLC detection for the preview window. - Put in the infrastructure for the new Frame / Duration(Seconds) feature - Some Re-factoring git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3050 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/QueryGenerator.cs82
-rw-r--r--win/C#/Functions/Scan.cs10
2 files changed, 53 insertions, 39 deletions
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index 2d2bd2a81..bfe456dc7 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -18,16 +18,16 @@ namespace Handbrake.Functions
/// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.
/// </summary>
/// <param name="mainWindow"></param>
+ /// <param name="mode"></param>
/// <param name="duration"></param>
/// <param name="preview"></param>
/// <returns></returns>
- public string GenerateCLIQuery(frmMain mainWindow, int duration, string preview)
+ public string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview)
{
string query = "";
-
- if (!string.IsNullOrEmpty(mainWindow.sourcePath))
- if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")
- query = " -i " + '"' + mainWindow.sourcePath + '"';
+
+ if (!string.IsNullOrEmpty(mainWindow.sourcePath) && mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")
+ query = " -i " + '"' + mainWindow.sourcePath + '"';
if (mainWindow.drp_dvdtitle.Text != "")
{
@@ -35,32 +35,46 @@ namespace Handbrake.Functions
query += " -t " + titleInfo[0];
}
- if (!Properties.Settings.Default.noDvdNav)
- if (mainWindow.drop_angle.Items.Count != 0)
- query += " --angle " + mainWindow.drop_angle.SelectedItem;
-
+ if (!Properties.Settings.Default.noDvdNav && mainWindow.drop_angle.Items.Count != 0)
+ query += " --angle " + mainWindow.drop_angle.SelectedItem;
- if (duration != 0 && preview != null) // Preivew Query
+ // Decide what part of the video we want to encode.
+ switch (mode)
{
- query += " --previews " + Properties.Settings.Default.previewScanCount + " ";
- query += " --start-at-preview " + preview;
- query += " --stop-at duration:" + duration + " ";
+ case 0: // Chapters
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
+ query += string.Format(" -c {0}", mainWindow.drop_chapterStart.Text);
+ else if (mainWindow.drop_chapterStart.Text != "" && mainWindow.drop_chapterFinish.Text != "")
+ query += string.Format(" -c {0}-{1}", mainWindow.drop_chapterStart.Text, mainWindow.drop_chapterFinish.Text);
+ break;
+ case 1: // Seconds
+ int start, end;
+ int.TryParse(mainWindow.drop_chapterStart.Text, out start);
+ int.TryParse(mainWindow.drop_chapterFinish.Text, out end);
+ int calculatedDuration = end - start;
- if (mainWindow.text_destination.Text != "")
- query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';
- }
- else // Non Preview Query
- {
- if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
- query += " -c " + mainWindow.drop_chapterStart.Text;
- else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
- query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;
- else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")
- query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;
-
- if (mainWindow.text_destination.Text != "")
- query += " -o " + '"' + mainWindow.text_destination.Text + '"';
+ query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", mainWindow.drop_chapterStart.Text, calculatedDuration);
+ break;
+ case 2: // Frames
+ int.TryParse(mainWindow.drop_chapterStart.Text, out start);
+ int.TryParse(mainWindow.drop_chapterFinish.Text, out end);
+ calculatedDuration = end - start;
+
+ query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", mainWindow.drop_chapterStart.Text, calculatedDuration);
+ break;
+ case 3: // Preview
+ query += " --previews " + Properties.Settings.Default.previewScanCount + " ";
+ query += " --start-at-preview " + preview;
+ query += " --stop-at duration:" + duration + " ";
+
+ if (mainWindow.text_destination.Text != "")
+ query += string.Format(" -o \"{0}\" ", mainWindow.text_destination.Text.Replace(".m", "_sample.m"));
+ break;
+ default:
+ break;
}
+ if (mode != 3)
+ query += string.Format(" -o \"{0}\" ", mainWindow.text_destination.Text);
query += GenerateTabbedComponentsQuery(mainWindow);
@@ -258,11 +272,11 @@ namespace Handbrake.Functions
// Audio Codec (-E)
if (row.SubItems[2].Text != String.Empty)
- codecs.Add(getAudioEncoder(row.SubItems[2].Text));
+ codecs.Add(GetAudioEncoder(row.SubItems[2].Text));
// Audio Mixdown (-6)
if (row.SubItems[3].Text != String.Empty)
- mixdowns.Add(getMixDown(row.SubItems[3].Text));
+ mixdowns.Add(GetMixDown(row.SubItems[3].Text));
// Sample Rate (-R)
if (row.SubItems[4].Text != String.Empty)
@@ -377,7 +391,7 @@ namespace Handbrake.Functions
string subtitleForced = String.Empty;
string subtitleBurn = String.Empty;
string subtitleDefault = String.Empty;
-
+
// SRT
string srtFile = String.Empty;
string srtCodeset = String.Empty;
@@ -499,7 +513,7 @@ namespace Handbrake.Functions
? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv")
: Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");
- if (chapterCSVSave(mainWindow, path) == false)
+ if (ChapterCSVSave(mainWindow, path) == false)
query += " -m ";
else
query += " --markers=" + "\"" + path + "\"";
@@ -528,7 +542,7 @@ namespace Handbrake.Functions
return query;
}
- private static string getMixDown(string selectedAudio)
+ private static string GetMixDown(string selectedAudio)
{
switch (selectedAudio)
{
@@ -548,7 +562,7 @@ namespace Handbrake.Functions
return "auto";
}
}
- private static string getAudioEncoder(string selectedEncoder)
+ private static string GetAudioEncoder(string selectedEncoder)
{
switch (selectedEncoder)
{
@@ -566,7 +580,7 @@ namespace Handbrake.Functions
return "";
}
}
- private static Boolean chapterCSVSave(frmMain mainWindow, string filePathName)
+ private static Boolean ChapterCSVSave(frmMain mainWindow, string filePathName)
{
try
{
diff --git a/win/C#/Functions/Scan.cs b/win/C#/Functions/Scan.cs
index aca3399f3..1aadf0afd 100644
--- a/win/C#/Functions/Scan.cs
+++ b/win/C#/Functions/Scan.cs
@@ -23,10 +23,10 @@ namespace Handbrake.Functions
public event EventHandler ScanCompleted;
public event EventHandler ScanStatusChanged;
- public void ScanSource(string sourcePath)
+ public void ScanSource(string sourcePath, int title)
{
- Thread t = new Thread(new ParameterizedThreadStart(RunScan));
- t.Start(sourcePath);
+ Thread t = new Thread(unused => RunScan(sourcePath, title));
+ t.Start();
}
public DVD SouceData()
@@ -49,7 +49,7 @@ namespace Handbrake.Functions
return _hbProc;
}
- private void RunScan(object sourcePath)
+ private void RunScan(object sourcePath, int title)
{
try
{
@@ -73,7 +73,7 @@ namespace Handbrake.Functions
StartInfo =
{
FileName = handbrakeCLIPath,
- Arguments = String.Format(@" -i ""{0}"" -t0 {1} -v ", sourcePath, dvdnav),
+ Arguments = String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav),
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,