diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Functions')
3 files changed, 52 insertions, 34 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs b/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs index ba6331fcf..fac4dd17c 100644 --- a/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Functions/Converters.cs @@ -10,8 +10,6 @@ namespace HandBrake.ApplicationServices.Functions using HandBrake.Interop.Model.Encoding;
- using AudioEncoder = HandBrake.ApplicationServices.Model.Encoding.AudioEncoder;
- using Mixdown = HandBrake.ApplicationServices.Model.Encoding.Mixdown;
using OutputFormat = HandBrake.ApplicationServices.Model.Encoding.OutputFormat;
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs index 53d7f6069..ad565f0b7 100644 --- a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs @@ -41,7 +41,7 @@ namespace HandBrake.ApplicationServices.Functions /// </summary>
/// <param name="value">An Enum with Display Attributes</param>
/// <returns>A string name</returns>
- public static string GetDisplayValue(T value)
+ public static string GetDisplay(T value)
{
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
DisplayAttribute[] attributes = (DisplayAttribute[])fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false);
@@ -59,7 +59,8 @@ namespace HandBrake.ApplicationServices.Functions foreach (T val in Enum.GetValues(typeof(T)))
{
string currDescription = GetDescription(val);
- if (currDescription == description)
+ string currDisplay = GetDisplay(val);
+ if (currDescription == description || currDisplay == description)
{
return val;
}
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs index da7303c01..62fe16120 100644 --- a/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Functions/InteropModelCreator.cs @@ -46,12 +46,18 @@ namespace HandBrake.ApplicationServices.Functions // Which will be converted to this EncodeJob Model.
EncodeJob job = new EncodeJob();
+
+
+
+
+
EncodingProfile profile = new EncodingProfile();
job.EncodingProfile = profile;
profile.Anamorphic = work.Anamorphic;
profile.AudioEncodings = new List<AudioEncoding>();
+ job.ChosenAudioTracks = new List<int>();
foreach (AudioTrack track in work.AudioTracks)
{
AudioEncoding newTrack = new AudioEncoding
@@ -59,16 +65,19 @@ namespace HandBrake.ApplicationServices.Functions Bitrate = track.Bitrate,
Drc = track.DRC,
Gain = track.Gain,
- //Encoder = track.Encoder,
- // InputNumber = track.Track,
- //Mixdown = track.MixDown,
- //SampleRateRaw = track.SampleRate
+ Encoder = track.Encoder,
+ InputNumber = track.Track.HasValue ? track.Track.Value : 0,
+ Mixdown = track.MixDown,
+ SampleRateRaw = GetSampleRateRaw(track.SampleRate),
};
profile.AudioEncodings.Add(newTrack);
+ if (track.Track != null)
+ {
+ job.ChosenAudioTracks.Add(track.Track.Value);
+ }
}
-
- profile.Cropping = new HandBrake.Interop.Model.Cropping
+ profile.Cropping = new Cropping
{
Top = work.Cropping.Top,
Bottom = work.Cropping.Bottom,
@@ -117,34 +126,17 @@ namespace HandBrake.ApplicationServices.Functions switch (work.OutputFormat)
{
case OutputFormat.Mp4:
- profile.PreferredExtension = Interop.Model.Encoding.OutputExtension.Mp4;
+ profile.PreferredExtension = OutputExtension.Mp4;
break;
case OutputFormat.M4V:
- profile.PreferredExtension = Interop.Model.Encoding.OutputExtension.M4v;
+ profile.PreferredExtension = OutputExtension.M4v;
break;
}
profile.Quality = work.Quality.HasValue ? work.Quality.Value : 0;
profile.UseDisplayWidth = true;
profile.VideoBitrate = work.VideoBitrate.HasValue ? work.VideoBitrate.Value : 0;
profile.VideoEncodeRateType = work.VideoEncodeRateType;
-
- switch (work.VideoEncoder)
- {
- case VideoEncoder.X264:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.X264;
- break;
- case VideoEncoder.FFMpeg:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.FFMpeg;
- break;
- case VideoEncoder.FFMpeg2:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.FFMpeg; // TODO Fix This.
- break;
- case VideoEncoder.Theora:
- profile.VideoEncoder = Interop.Model.Encoding.VideoEncoder.Theora;
- break;
-
- }
-
+ profile.VideoEncoder = work.VideoEncoder;
profile.Width = work.Width.HasValue ? work.Width.Value : 0;
profile.X264Options = work.AdvancedEncoderOptions;
@@ -162,6 +154,9 @@ namespace HandBrake.ApplicationServices.Functions job.FramesStart = work.StartPoint;
}
+ job.CustomChapterNames = work.ChapterNames;
+ job.UseDefaultChapterNames = work.IncludeChapterMarkers;
+
job.OutputPath = work.Destination;
switch (work.PointToPointMode)
{
@@ -186,14 +181,38 @@ namespace HandBrake.ApplicationServices.Functions job.SourcePath = work.Source;
// job.SourceType = work.Type;
job.Title = work.Title;
+
+ // TODO Setup subtitles
job.Subtitles = new Subtitles { SourceSubtitles = new List<SourceSubtitle>(), SrtSubtitles = new List<SrtSubtitle>() };
- foreach (SubtitleTrack track in work.SubtitleTracks)
- {
- // TODO
- }
+ //foreach (SubtitleTrack track in work.SubtitleTracks)
+ //{
+ // // TODO
+ //}
return job;
}
+
+ /// <summary>
+ /// Get the Raw Sample Rate
+ /// </summary>
+ /// <param name="rate">
+ /// The rate.
+ /// </param>
+ /// <returns>
+ /// The Raw sample rate as an int
+ /// </returns>
+ private static int GetSampleRateRaw(double rate)
+ {
+ if (rate == 22.05)
+ return 22050;
+ else if (rate == 24)
+ return 24000;
+ else if (rate == 44.1)
+ return 32000;
+ else if (rate == 48)
+ return 48000;
+ else return 48000;
+ }
}
}
|