diff options
author | sr55 <[email protected]> | 2014-11-28 22:03:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-11-28 22:03:12 +0000 |
commit | b332cc6dcc28d06f20e81fd44af2e39fba8b80e9 (patch) | |
tree | d078e6e8d6bf6dc53cc8120841e750023edba1b0 /win | |
parent | ddb65ae750d04f5972e9e30c0e6721644bb03ef2 (diff) |
WinGui: Stop using HandBrakeCLI to fetch preset information. Removing another instance where we rely on HandBrakeCLI.exe. For now, it's just using a local copy of it's output that will be manually updated from now on. This changes infrequently so should not be an issue.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6563 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Presets.dat | 31 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Presets/PresetService.cs | 59 |
3 files changed, 53 insertions, 39 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 4fd168aee..cee9ac57e 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -373,6 +373,7 @@ <None Include="Installer\Installer64.nsi" />
<None Include="Installer\MakeNightly.nsi.tmpl" />
<None Include="Installer\MakeNightly64.nsi.tmpl" />
+ <EmbeddedResource Include="Presets.dat" />
<None Include="Properties\AssemblyInfo.cs.Nightly.tmpl" />
<None Include="Properties\AssemblyInfo.cs.tmpl" />
<None Include="Properties\Settings.settings">
@@ -505,7 +506,6 @@ </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="defaultsettings.xml">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</EmbeddedResource>
<Resource Include="Views\Images\add40.png" />
diff --git a/win/CS/HandBrakeWPF/Presets.dat b/win/CS/HandBrakeWPF/Presets.dat new file mode 100644 index 000000000..45ceaacca --- /dev/null +++ b/win/CS/HandBrakeWPF/Presets.dat @@ -0,0 +1,31 @@ +< Devices
+
+ + Universal: -e x264 -q 20.0 -r 30 --pfr -a 1,1 -E ffaac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 720 -Y 576 --loose-anamorphic --modulus 2 -m --x264-preset fast --h264-profile baseline --h264-level 3.0
+
+ + iPod: -e x264 -q 22.0 -r 30 --pfr -a 1 -E ffaac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -I -X 320 -Y 240 --modulus 2 -m --x264-preset medium --h264-profile baseline --h264-level 1.3
+
+ + iPhone & iPod touch: -e x264 -q 22.0 -r 30 --pfr -a 1 -E ffaac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 960 -Y 640 --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 3.1
+
+ + iPad: -e x264 -q 20.0 -r 30 --pfr -a 1 -E ffaac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 3.1
+
+ + AppleTV: -e x264 -q 20.0 -r 30 --pfr -a 1,1 -E ffaac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 960 -Y 720 --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 3.1 -x qpmin=4:cabac=0:ref=2:b-pyramid=none:weightb=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500
+
+ + AppleTV 2: -e x264 -q 20.0 -r 30 --pfr -a 1,1 -E ffaac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 3.1
+
+ + AppleTV 3: -e x264 -q 20.0 -r 30 --pfr -a 1,1 -E ffaac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 1920 -Y 1080 --decomb=fast --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.0
+
+ + Android: -e x264 -q 22.0 -r 30 --pfr -a 1 -E ffaac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 720 -Y 576 --loose-anamorphic --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.0
+
+ + Android Tablet: -e x264 -q 22.0 -r 30 --pfr -a 1 -E ffaac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.1
+
+ + Windows Phone 8: -e x264 -q 22.0 -r 30 --pfr -a 1 -E ffaac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 1280 -Y 720 --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.1
+
+>
+
+< Regular
+
+ + Normal: -e x264 -q 20.0 -a 1 -E ffaac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 --loose-anamorphic --modulus 2 -m --x264-preset veryfast --h264-profile main --h264-level 4.0
+
+ + High Profile: -e x264 -q 20.0 -a 1,1 -E ffaac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 --decomb --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.1
+
+>
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index e7a2b8afb..48c3409cb 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -12,9 +12,9 @@ namespace HandBrakeWPF.Services.Presets using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
- using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
@@ -125,7 +125,7 @@ namespace HandBrakeWPF.Services.Presets this.UpdatePresetFiles();
return true;
}
-
+
this.Update(preset);
return true;
}
@@ -252,32 +252,20 @@ namespace HandBrakeWPF.Services.Presets /// </summary>
public void UpdateBuiltInPresets()
{
- // Create a new tempory file and execute the CLI to get the built in Presets.
- string handbrakeCLIPath = Path.Combine(System.Windows.Forms.Application.StartupPath, "HandBrakeCLI.exe");
- string presetsPath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");
- string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
-
- ProcessStartInfo getPresets = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden };
-
- Process hbproc = Process.Start(getPresets);
- hbproc.WaitForExit();
- hbproc.Dispose();
- hbproc.Close();
-
// Clear the current built in Presets and now parse the tempory Presets file.
this.ClearBuiltIn();
- if (File.Exists(presetsPath))
+ using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HandBrakeWPF.Presets.dat"))
{
- using (StreamReader presetInput = new StreamReader(presetsPath))
+ using (StreamReader reader = new StreamReader(stream))
{
StringBuilder contents = new StringBuilder();
string category = String.Empty;
- while (!presetInput.EndOfStream)
+ while (!reader.EndOfStream)
{
- string line = presetInput.ReadLine();
+ string line = reader.ReadLine();
contents.AppendLine(line);
// Found the beginning of a preset block )
@@ -293,15 +281,15 @@ namespace HandBrakeWPF.Services.Presets string[] presetName = r.Split(line);
Preset newPreset = new Preset
- {
- Category = category,
- Name = presetName[0].Replace("+", string.Empty).Trim(),
- Version = VersionHelper.GetVersion(),
- Description = string.Empty, // Maybe one day we will populate this.
- IsBuildIn = true,
- UsePictureFilters = true,
- Task = QueryParserUtility.Parse(presetName[2])
- };
+ {
+ Category = category,
+ Name = presetName[0].Replace("+", string.Empty).Trim(),
+ Version = VersionHelper.GetVersion(),
+ Description = string.Empty, // Maybe one day we will populate this.
+ IsBuildIn = true,
+ UsePictureFilters = true,
+ Task = QueryParserUtility.Parse(presetName[2])
+ };
if (newPreset.Name == "iPod")
{
@@ -309,7 +297,7 @@ namespace HandBrakeWPF.Services.Presets }
newPreset.Task.AllowedPassthruOptions = new AllowedPassthru(true); // We don't want to override the built-in preset
-
+
if (newPreset.Name == "Normal")
{
newPreset.IsDefault = true;
@@ -325,11 +313,6 @@ namespace HandBrakeWPF.Services.Presets throw new GeneralApplicationException("Failed to load built-in presets.", "Restarting HandBrake may resolve this issue", new Exception(contents.ToString()));
}
}
- }
- else
- {
- // Something really bad must have happened if the file is missing.
- throw new GeneralApplicationException("Preset Export Failed. Unable to load in Presets.", "Please restart HandBrake", null);
}
// Finally, Create a new or update the current Presets.xml file
@@ -354,7 +337,7 @@ namespace HandBrakeWPF.Services.Presets this.UpdateBuiltInPresets();
return true;
}
- }
+ }
}
return false;
@@ -409,7 +392,7 @@ namespace HandBrakeWPF.Services.Presets File.Delete(file);
}
}
- }
+ }
catch (IOException)
{
// Give up
@@ -435,11 +418,11 @@ namespace HandBrakeWPF.Services.Presets foreach (Preset preset in list)
{
preset.IsBuildIn = true;
- // Older versions did not have this flag so explicitly make sure it is set.
+ // Older versions did not have this flag so explicitly make sure it is set.
this.presets.Add(preset);
}
}
- }
+ }
}
catch (Exception)
{
@@ -465,7 +448,7 @@ namespace HandBrakeWPF.Services.Presets catch (Exception exc)
{
RecoverFromCorruptedPresetFile(this.userPresetFile);
- throw new GeneralApplicationException("HandBrake has detected a problem with your presets.", "Your old presets file has been renamed so that it doesn't get loaded on next launch.", exc);
+ throw new GeneralApplicationException("HandBrake has detected a problem with your presets.", "Your old presets file has been renamed so that it doesn't get loaded on next launch.", exc);
}
}
|