diff options
author | sr55 <[email protected]> | 2013-09-21 17:47:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-09-21 17:47:12 +0000 |
commit | 515f8070a43f25de58019314bf6893c12a478c76 (patch) | |
tree | 7829f0ee63671b77a900c2614e694057110fc2c8 /win/CS/HandBrake.ApplicationServices/Utilities | |
parent | bb3aae9dd06271ab7b18a2d55fec14c97b76e9b0 (diff) |
WinGui: Fix up libhb encode feature.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5790 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs | 163 |
1 files changed, 89 insertions, 74 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index b6a50485f..81b4a63c1 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -17,6 +17,7 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Encoding.x264;
/// <summary>
/// A Utility Class to Convert a
@@ -45,12 +46,10 @@ namespace HandBrake.ApplicationServices.Utilities // Which will be converted to this EncodeJob Model.
EncodeJob job = new EncodeJob();
-
EncodingProfile profile = new EncodingProfile();
job.EncodingProfile = profile;
- profile.Anamorphic = work.Anamorphic;
-
+ // Audio Settings
profile.AudioEncodings = new List<AudioEncoding>();
job.ChosenAudioTracks = new List<int>();
foreach (AudioTrack track in work.AudioTracks)
@@ -63,7 +62,7 @@ namespace HandBrake.ApplicationServices.Utilities Encoder = Converters.GetCliAudioEncoder(track.Encoder),
InputNumber = track.Track.HasValue ? track.Track.Value : 0,
Mixdown = Converters.GetCliMixDown(track.MixDown),
- SampleRateRaw = GetSampleRateRaw(track.SampleRate),
+ SampleRateRaw = GetSampleRateRaw(track.SampleRate),
};
profile.AudioEncodings.Add(newTrack);
@@ -72,6 +71,60 @@ namespace HandBrake.ApplicationServices.Utilities job.ChosenAudioTracks.Add(track.Track.Value);
}
}
+
+ // Title Settings
+ job.OutputPath = work.Destination;
+ job.SourcePath = work.Source;
+ job.Title = work.Title;
+ // job.SourceType = work.Type;
+ switch (work.PointToPointMode)
+ {
+ case PointToPointMode.Chapters:
+ job.RangeType = VideoRangeType.Chapters;
+ break;
+ case PointToPointMode.Seconds:
+ job.RangeType = VideoRangeType.Seconds;
+ break;
+ case PointToPointMode.Frames:
+ job.RangeType = VideoRangeType.Frames;
+ break;
+ }
+
+ if (work.PointToPointMode == PointToPointMode.Seconds)
+ {
+ job.SecondsEnd = work.EndPoint;
+ job.SecondsStart = work.StartPoint;
+ }
+ if (work.PointToPointMode == PointToPointMode.Chapters)
+ {
+ job.ChapterStart = work.StartPoint;
+ job.ChapterEnd = work.EndPoint;
+ }
+ if (work.PointToPointMode == PointToPointMode.Frames)
+ {
+ job.FramesEnd = work.EndPoint;
+ job.FramesStart = work.StartPoint;
+ }
+
+ job.Angle = work.Angle;
+ job.EncodingProfile = profile;
+
+ // Output Settings
+ profile.IPod5GSupport = work.IPod5GSupport;
+ profile.Optimize = work.OptimizeMP4;
+ switch (work.OutputFormat)
+ {
+ case OutputFormat.Mp4:
+ case OutputFormat.M4V:
+ profile.OutputFormat = Container.Mp4;
+ break;
+ case OutputFormat.Mkv:
+ profile.OutputFormat = Container.Mkv;
+ break;
+ }
+
+ // Picture Settings
+ profile.Anamorphic = work.Anamorphic;
profile.Cropping = new Cropping
{
Top = work.Cropping.Top,
@@ -79,101 +132,63 @@ namespace HandBrake.ApplicationServices.Utilities Left = work.Cropping.Left,
Right = work.Cropping.Right
};
-
profile.CroppingType = CroppingType.Custom; // TODO deal with this better
+ profile.DisplayWidth = work.DisplayWidth.HasValue
+ ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString())
+ : 0;
+ profile.PixelAspectX = work.PixelAspectX;
+ profile.PixelAspectY = work.PixelAspectY;
+ profile.Height = work.Height.HasValue ? work.Height.Value : 0;
+ profile.KeepDisplayAspect = work.KeepDisplayAspect;
+ profile.MaxHeight = work.MaxHeight.HasValue ? work.MaxHeight.Value : 0;
+ profile.MaxWidth = work.MaxWidth.HasValue ? work.MaxWidth.Value : 0;
+ profile.Modulus = work.Modulus.HasValue ? work.Modulus.Value : 16;
+ profile.UseDisplayWidth = true;
+ profile.Width = work.Width.HasValue ? work.Width.Value : 0;
+
+ // Filter Settings
profile.CustomDecomb = work.CustomDecomb;
profile.CustomDeinterlace = work.CustomDeinterlace;
profile.CustomDenoise = work.CustomDenoise;
profile.CustomDetelecine = work.CustomDetelecine;
- profile.Deblock = work.Deblock;
+ if (work.Deblock > 4)
+ profile.Deblock = work.Deblock;
profile.Decomb = work.Decomb;
profile.Deinterlace = work.Deinterlace;
profile.Denoise = work.Denoise;
profile.Detelecine = work.Detelecine;
- profile.DisplayWidth = work.DisplayWidth.HasValue
- ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString())
- : 0;
- profile.Framerate = work.Framerate.HasValue ? work.Framerate.Value : 0;
profile.Grayscale = work.Grayscale;
- profile.Height = work.Height.HasValue ? work.Height.Value : 0;
- profile.IPod5GSupport = work.IPod5GSupport;
- profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
- profile.KeepDisplayAspect = work.KeepDisplayAspect;
- profile.MaxHeight = work.MaxHeight.HasValue ? work.MaxHeight.Value : 0;
- profile.MaxWidth = work.MaxWidth.HasValue ? work.MaxWidth.Value : 0;
- profile.Modulus = work.Modulus.HasValue ? work.Modulus.Value : 16;
- profile.Optimize = work.OptimizeMP4;
- switch (work.OutputFormat)
- {
- case OutputFormat.Mp4:
- case OutputFormat.M4V:
- profile.OutputFormat = Container.Mp4;
- break;
- case OutputFormat.Mkv:
- profile.OutputFormat = Container.Mkv;
- break;
- }
- profile.ConstantFramerate = work.FramerateMode == FramerateMode.CFR;
- profile.PixelAspectX = work.PixelAspectX;
- profile.PixelAspectY = work.PixelAspectY;
- switch (work.OutputFormat)
- {
- case OutputFormat.Mp4:
- profile.PreferredExtension = OutputExtension.Mp4;
- break;
- case OutputFormat.M4V:
- profile.PreferredExtension = OutputExtension.M4v;
- break;
- }
+ // Video Settings
+ profile.Framerate = work.Framerate.HasValue ? work.Framerate.Value : 0;
+ profile.ConstantFramerate = work.FramerateMode == FramerateMode.CFR;
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;
profile.VideoEncoder = Converters.GetVideoEncoder(work.VideoEncoder);
- profile.Width = work.Width.HasValue ? work.Width.Value : 0;
- profile.X264Options = work.AdvancedEncoderOptions;
- if (work.PointToPointMode == PointToPointMode.Chapters)
+ profile.H264Level = work.H264Level;
+ profile.X264Profile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty); // TODO change these away from strings.
+ profile.X264Preset = work.X264Preset.ToString().ToLower().Replace(" ", string.Empty);
+ profile.X264Tunes = new List<string>();
+
+ if (work.X264Tune != x264Tune.None)
{
- job.ChapterStart = work.StartPoint;
- job.ChapterEnd = work.EndPoint;
+ profile.X264Tunes.Add(work.X264Tune.ToString().ToLower().Replace(" ", string.Empty));
}
- job.Angle = work.Angle;
- job.EncodingProfile = profile;
- if (work.PointToPointMode == PointToPointMode.Frames)
+ if (work.FastDecode)
{
- job.FramesEnd = work.EndPoint;
- job.FramesStart = work.StartPoint;
+ profile.X264Tunes.Add("fastdecode");
}
+ // Chapter Markers
+ profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
job.UseDefaultChapterNames = work.IncludeChapterMarkers;
- job.OutputPath = work.Destination;
- switch (work.PointToPointMode)
- {
- case PointToPointMode.Chapters:
- job.RangeType = VideoRangeType.Chapters;
- break;
- case PointToPointMode.Seconds:
- job.RangeType = VideoRangeType.Seconds;
- break;
- case PointToPointMode.Frames:
- job.RangeType = VideoRangeType.Frames;
- break;
- }
-
- if (work.PointToPointMode == PointToPointMode.Seconds)
- {
- job.SecondsEnd = work.EndPoint;
- job.SecondsStart = work.StartPoint;
- }
-
- job.SourcePath = work.Source;
- // job.SourceType = work.Type;
- job.Title = work.Title;
+ // Advanced Settings
+ profile.X264Options = work.AdvancedEncoderOptions;
// Subtitles
job.Subtitles = new Subtitles { SourceSubtitles = new List<SourceSubtitle>(), SrtSubtitles = new List<SrtSubtitle>() };
|