summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/CS/HandBrake.ApplicationServices/Attributes/ShortName.cs (renamed from win/CS/HandBrake.ApplicationServices/Interop/Attributes/ShortName.cs)2
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs27
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstanceManager.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs8
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/AnamorphicFactory.cs12
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/EncodeJob.cs505
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncodeRateType.cs21
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoding.cs89
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/VideoEncoder.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs (renamed from win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/OutputExtension.cs)14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs20
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs60
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/SrtSubtitle.cs66
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/Subtitles.cs29
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Model/VideoRangeType.cs43
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs (renamed from win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/EncodeFactory.cs)234
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs11
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs267
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs5
24 files changed, 266 insertions, 1177 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Attributes/ShortName.cs b/win/CS/HandBrake.ApplicationServices/Attributes/ShortName.cs
index 55df6136e..eab372e34 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Attributes/ShortName.cs
+++ b/win/CS/HandBrake.ApplicationServices/Attributes/ShortName.cs
@@ -7,7 +7,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Attributes
+namespace HandBrake.ApplicationServices.Attributes
{
using System;
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 6f2826306..28cac05c0 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -89,7 +89,7 @@
<ItemGroup>
<Compile Include="Converters\EnumToDescConverter.cs" />
<Compile Include="Exceptions\GeneralApplicationException.cs" />
- <Compile Include="Interop\Attributes\ShortName.cs" />
+ <Compile Include="Attributes\ShortName.cs" />
<Compile Include="Interop\EventArgs\EncodeCompletedEventArgs.cs" />
<Compile Include="Interop\EventArgs\EncodeProgressEventArgs.cs" />
<Compile Include="Interop\EventArgs\MessageLoggedEventArgs.cs" />
@@ -142,7 +142,7 @@
<Compile Include="Interop\Json\Encode\SubtitleList.cs" />
<Compile Include="Interop\Json\Encode\Video.cs" />
<Compile Include="Interop\Json\Factories\AnamorphicFactory.cs" />
- <Compile Include="Interop\Json\Factories\EncodeFactory.cs" />
+ <Compile Include="Services\Encode\Factories\EncodeFactory.cs" />
<Compile Include="Interop\Json\Factories\ScanFactory.cs" />
<Compile Include="Interop\Json\Scan\AudioList.cs" />
<Compile Include="Interop\Json\Scan\ChapterList.cs" />
@@ -162,11 +162,8 @@
<Compile Include="Interop\Json\State\Working.cs" />
<Compile Include="Interop\Model\BitrateLimits.cs" />
<Compile Include="Interop\Model\Cropping.cs" />
- <Compile Include="Interop\Model\EncodeJob.cs" />
<Compile Include="Interop\Model\Encoding\Anamorphic.cs" />
<Compile Include="Interop\Model\Encoding\AudioEncoder.cs" />
- <Compile Include="Interop\Model\Encoding\AudioEncodeRateType.cs" />
- <Compile Include="Interop\Model\Encoding\AudioEncoding.cs" />
<Compile Include="Interop\Model\Encoding\Container.cs" />
<Compile Include="Interop\Model\Encoding\Decomb.cs" />
<Compile Include="Interop\Model\Encoding\Deinterlace.cs" />
@@ -178,12 +175,12 @@
<Compile Include="Interop\Model\Encoding\HBRate.cs" />
<Compile Include="Interop\Model\Encoding\HBVideoEncoder.cs" />
<Compile Include="Interop\Model\Encoding\Mixdown.cs" />
- <Compile Include="Interop\Model\Encoding\OutputExtension.cs" />
<Compile Include="Interop\Model\Encoding\PictureRotation.cs" />
<Compile Include="Interop\Model\Encoding\ScaleMethod.cs" />
<Compile Include="Interop\Model\Encoding\VideoEncoder.cs" />
<Compile Include="Interop\Model\Encoding\VideoEncodeRateType.cs" />
<Compile Include="Interop\Model\Language.cs" />
+ <Compile Include="Interop\Model\Preview\PreviewSettings.cs" />
<Compile Include="Interop\Model\RangeLimits.cs" />
<Compile Include="Interop\Model\Scan\AudioTrack.cs" />
<Compile Include="Interop\Model\Scan\Chapter.cs" />
@@ -192,12 +189,10 @@
<Compile Include="Interop\Model\Scan\SubtitleSource.cs" />
<Compile Include="Interop\Model\Scan\Title.cs" />
<Compile Include="Interop\Model\Size.cs" />
+ <Compile Include="Interop\Model\SourceVideoInfo.cs" />
<Compile Include="Interop\Model\SourceSubtitle.cs" />
<Compile Include="Interop\Model\SourceType.cs" />
- <Compile Include="Interop\Model\SrtSubtitle.cs" />
- <Compile Include="Interop\Model\Subtitles.cs" />
<Compile Include="Interop\Model\VideoQualityLimits.cs" />
- <Compile Include="Interop\Model\VideoRangeType.cs" />
<Compile Include="Services\Encode\Factories\VideoProfileFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoPresetFactory.cs" />
<Compile Include="Services\Encode\Factories\VideoLevelFactory.cs" />
@@ -216,7 +211,6 @@
<Compile Include="Services\Scan\EventArgs\ScanProgressEventArgs.cs" />
<Compile Include="Utilities\Converters.cs" />
<Compile Include="Utilities\EnumHelper.cs" />
- <Compile Include="Utilities\InteropModelCreator.cs" />
<Compile Include="Utilities\SystemInfo.cs" />
<Compile Include="Utilities\VersionHelper.cs" />
<Compile Include="Utilities\Win32.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs
index 82e44c04a..4a52a30cc 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs
@@ -31,6 +31,7 @@ namespace HandBrake.ApplicationServices.Interop
using HandBrake.ApplicationServices.Interop.Json.State;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Interop.Model.Scan;
using Newtonsoft.Json;
@@ -40,7 +41,7 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// A wrapper for a HandBrake instance.
/// </summary>
- public class HandBrakeInstance : IHandBrakeInstance, IDisposable
+ internal class HandBrakeInstance : IHandBrakeInstance, IDisposable
{
/// <summary>
/// The number of MS between status polls when scanning.
@@ -243,8 +244,8 @@ namespace HandBrake.ApplicationServices.Interop
/// <returns>
/// An image with the requested preview.
/// </returns>
- [HandleProcessCorruptedStateExceptions]
- public BitmapImage GetPreview(EncodeJob job, int previewNumber)
+ [HandleProcessCorruptedStateExceptions]
+ public BitmapImage GetPreview(PreviewSettings job, int previewNumber)
{
Title title = this.Titles.FirstOrDefault(t => t.TitleNumber == job.Title);
Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");
@@ -255,14 +256,14 @@ namespace HandBrake.ApplicationServices.Interop
crop = new[] { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right },
itu_par = 0,
keep = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (job.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
- maxWidth = job.MaxWidth,
- maxHeight = job.MaxHeight,
+ maxWidth = job.MaxWidth ?? 0,
+ maxHeight = job.MaxHeight ?? 0,
mode = (int)(hb_anamorphic_mode_t)job.Anamorphic,
- modulus = job.Modulus,
+ modulus = job.Modulus ?? 16,
geometry = new hb_geometry_s
{
- height = job.Height,
- width = job.Width,
+ height = job.Height ?? 0,
+ width = job.Width ?? 0,
par = job.Anamorphic != Anamorphic.Custom
? new hb_rational_t { den = title.ParVal.Height, num = title.ParVal.Width }
: new hb_rational_t { den = job.PixelAspectY, num = job.PixelAspectX }
@@ -270,7 +271,7 @@ namespace HandBrake.ApplicationServices.Interop
};
// Sanatise the input.
- Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, title, AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.
+ Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(title.FramerateNumerator, title.FramerateDenominator, title.Resolution, title.ParVal), AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.
int width = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den;
int height = resultGeometry.Height;
uiGeometry.geometry.height = resultGeometry.Height; // Prased the height now.
@@ -340,17 +341,15 @@ namespace HandBrake.ApplicationServices.Interop
/// <summary>
/// Starts an encode with the given job.
/// </summary>
- /// <param name="job">
- /// The job to start.
+ /// <param name="encodeObject">
+ /// The encode Object.
/// </param>
/// <param name="title">
/// The title.
/// </param>
[HandleProcessCorruptedStateExceptions]
- public void StartEncode(EncodeJob job, Title title)
+ public void StartEncode(JsonEncodeObject encodeObject, Title title)
{
- JsonEncodeObject encodeObject = EncodeFactory.Create(job, title);
-
JsonSerializerSettings settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstanceManager.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstanceManager.cs
index 9dc3c1d79..7a2e93d1b 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstanceManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstanceManager.cs
@@ -17,7 +17,7 @@ namespace HandBrake.ApplicationServices.Interop
/// The HandBrake Instance manager.
/// Only supports scanning right now.
/// </summary>
- public static class HandBrakeInstanceManager
+ internal static class HandBrakeInstanceManager
{
private static HandBrakeInstance scanInstance;
private static HandBrakeInstance encodeInstance;
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs
index e416a7673..48be6bc40 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs
@@ -14,13 +14,15 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces
using System.Windows.Media.Imaging;
using HandBrake.ApplicationServices.Interop.EventArgs;
+ using HandBrake.ApplicationServices.Interop.Json.Encode;
using HandBrake.ApplicationServices.Interop.Model;
+ using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Interop.Model.Scan;
/// <summary>
/// The Interface for HandBrakeInstance
/// </summary>
- public interface IHandBrakeInstance
+ internal interface IHandBrakeInstance
{
#region Events
@@ -88,7 +90,7 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces
/// <returns>
/// An image with the requested preview.
/// </returns>
- BitmapImage GetPreview(EncodeJob job, int previewNumber);
+ BitmapImage GetPreview(PreviewSettings job, int previewNumber);
/// <summary>
/// Pauses the current encode.
@@ -109,7 +111,7 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces
/// <param name="title">
/// The title.
/// </param>
- void StartEncode(EncodeJob jobToStart, Title title);
+ void StartEncode(JsonEncodeObject jobToStart, Title title);
/// <summary>
/// Starts a scan of the given path.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/AnamorphicFactory.cs
index 9aa335a52..40a87dc05 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/AnamorphicFactory.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/AnamorphicFactory.cs
@@ -17,7 +17,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
+ using HandBrake.ApplicationServices.Services.Encode.Model;
using Newtonsoft.Json;
@@ -51,7 +51,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="Scan.Geometry"/>.
/// </returns>
- public static Geometry CreateGeometry(EncodeJob job, Title title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
+ public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
{
int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);
@@ -68,7 +68,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
{
AnamorphicMode = (int)job.Anamorphic,
Geometry = {
- Width = job.Width, Height = job.Height,
+ Width = job.Width ?? 0, Height = job.Height ?? 0,
PAR = new PAR
{
Num = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.PixelAspectX,
@@ -77,9 +77,9 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
},
Keep = settingMode,
Crop = new List<int> { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right },
- Modulus = job.Modulus,
- MaxWidth = job.MaxWidth,
- MaxHeight = job.MaxHeight,
+ Modulus = job.Modulus ?? 16,
+ MaxWidth = job.MaxWidth ?? 0,
+ MaxHeight = job.MaxHeight ?? 0,
ItuPAR = false
}
};
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/EncodeJob.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/EncodeJob.cs
deleted file mode 100644
index 9357e21a3..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/EncodeJob.cs
+++ /dev/null
@@ -1,505 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeJob.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the EncodeJob type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model
-{
- using System.Collections.Generic;
-
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
-
- /// <summary>
- /// The encode job.
- /// </summary>
- public class EncodeJob
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="EncodeJob"/> class.
- /// </summary>
- public EncodeJob()
- {
- this.Cropping = new Cropping();
- }
-
- #region Source
-
- /// <summary>
- /// Gets or sets the source path.
- /// </summary>
- public string SourcePath { get; set; }
-
- /// <summary>
- /// Gets or sets the 1-based index of the title to encode.
- /// </summary>
- public int Title { get; set; }
-
- /// <summary>
- /// Gets or sets the range type.
- /// </summary>
- public VideoRangeType RangeType { get; set; }
-
- /// <summary>
- /// Gets or sets the seek points.
- /// This is the number of preview points.
- /// </summary>
- public int SeekPoints { get; set; }
-
- /// <summary>
- /// Gets or sets the start at preview.
- /// </summary>
- public int StartAtPreview { get; set; }
-
- /// <summary>
- /// Gets or sets the seconds end.
- /// </summary>
- public int SecondsEnd { get; set; }
-
- /// <summary>
- /// Gets or sets the seconds start.
- /// </summary>
- public double SecondsStart { get; set; }
-
- /// <summary>
- /// Gets or sets the angle to encode. 0 for default, 1+ for specified angle.
- /// </summary>
- public int Angle { get; set; }
-
- /// <summary>
- /// Gets or sets the chapter end.
- /// </summary>
- public int ChapterEnd { get; set; }
-
- /// <summary>
- /// Gets or sets the chapter start.
- /// </summary>
- public int ChapterStart { get; set; }
-
- /// <summary>
- /// Gets or sets the frames end.
- /// </summary>
- public int FramesEnd { get; set; }
-
- /// <summary>
- /// Gets or sets the frames start.
- /// </summary>
- public int FramesStart { get; set; }
-
- /// <summary>
- /// Gets or sets the source type.
- /// </summary>
- public SourceType SourceType { get; set; }
-
- #endregion
-
- #region Destination and Output Settings
-
- /// <summary>
- /// Gets or sets the output path.
- /// </summary>
- public string OutputPath { get; set; }
-
- /// <summary>
- /// Gets or sets the container name.
- /// </summary>
- public string ContainerName { get; set; }
-
- /// <summary>
- /// Gets or sets the preferred extension.
- /// </summary>
- public OutputExtension PreferredExtension { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether include chapter markers.
- /// </summary>
- public bool IncludeChapterMarkers { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether optimize.
- /// </summary>
- public bool Optimize { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether i pod 5 g support.
- /// </summary>
- public bool IPod5GSupport { get; set; }
- #endregion
-
- #region Picture Settings
-
- /// <summary>
- /// Gets or sets the width.
- /// </summary>
- public int Width { get; set; }
-
- /// <summary>
- /// Gets or sets the height.
- /// </summary>
- public int Height { get; set; }
-
- /// <summary>
- /// Gets or sets the max width.
- /// </summary>
- public int MaxWidth { get; set; }
-
- /// <summary>
- /// Gets or sets the max height.
- /// </summary>
- public int MaxHeight { get; set; }
-
- /// <summary>
- /// Gets or sets the scale method.
- /// </summary>
- public ScaleMethod ScaleMethod { get; set; }
-
- /// <summary>
- /// Gets or sets the cropping.
- /// </summary>
- public Cropping Cropping { get; set; }
-
- /// <summary>
- /// Gets or sets the anamorphic.
- /// </summary>
- public Anamorphic Anamorphic { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether use display width.
- /// </summary>
- public bool UseDisplayWidth { get; set; }
-
- /// <summary>
- /// Gets or sets the display width.
- /// </summary>
- public int DisplayWidth { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether keep display aspect.
- /// </summary>
- public bool KeepDisplayAspect { get; set; }
-
- /// <summary>
- /// Gets or sets the pixel aspect x.
- /// </summary>
- public int PixelAspectX { get; set; }
-
- /// <summary>
- /// Gets or sets the pixel aspect y.
- /// </summary>
- public int PixelAspectY { get; set; }
-
- /// <summary>
- /// Gets or sets the modulus.
- /// </summary>
- public int Modulus { get; set; }
-
- /// <summary>
- /// Gets or sets the rotation.
- /// </summary>
- public PictureRotation Rotation { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the picture should be flipped horizontally.
- /// </summary>
- public bool FlipHorizontal { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the picture should be flipped vertically.
- /// </summary>
- public bool FlipVertical { get; set; }
- #endregion
-
- #region Filters
-
- /// <summary>
- /// Gets or sets the deinterlace.
- /// </summary>
- public Deinterlace Deinterlace { get; set; }
-
- /// <summary>
- /// Gets or sets the custom deinterlace.
- /// </summary>
- public string CustomDeinterlace { get; set; }
-
- /// <summary>
- /// Gets or sets the decomb.
- /// </summary>
- public Decomb Decomb { get; set; }
-
- /// <summary>
- /// Gets or sets the custom decomb.
- /// </summary>
- public string CustomDecomb { get; set; }
-
- /// <summary>
- /// Gets or sets the detelecine.
- /// </summary>
- public Detelecine Detelecine { get; set; }
-
- /// <summary>
- /// Gets or sets the custom detelecine.
- /// </summary>
- public string CustomDetelecine { get; set; }
-
- /// <summary>
- /// Gets or sets the denoise.
- /// </summary>
- public Denoise Denoise { get; set; }
-
- /// <summary>
- /// Gets or sets the denoise preset name.
- /// </summary>
- public string DenoisePreset { get; set; }
-
- /// <summary>
- /// Gets or sets the denoise tune name.
- /// </summary>
- public string DenoiseTune { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether we should use the provided
- /// custom denoise string or we should use the preset and tune.
- /// </summary>
- public bool UseCustomDenoise { get; set; }
-
- /// <summary>
- /// Gets or sets the custom denoise.
- /// </summary>
- public string CustomDenoise { get; set; }
-
- /// <summary>
- /// Gets or sets the deblock.
- /// </summary>
- public int Deblock { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the grayscale filter will be applied.
- /// </summary>
- public bool Grayscale { get; set; }
- #endregion
-
- #region Video
-
- /// <summary>
- /// Gets or sets the video encoder.
- /// </summary>
- public string VideoEncoder { get; set; }
-
- /// <summary>
- /// Gets or sets the video encoder options.
- /// </summary>
- public string VideoOptions { get; set; }
-
- /// <summary>
- /// Gets or sets the advanced options.
- /// This overrides the VideoOptions, VideoPreset, VideoTunes and VideoLevel
- /// </summary>
- public string AdvancedOptions { get; set; }
-
- /// <summary>
- /// Gets or sets the video encoder profile name.
- /// </summary>
- public string VideoProfile { get; set; }
-
- /// <summary>
- /// Gets or sets the video encoder preset name.
- /// </summary>
- public string VideoPreset { get; set; }
-
- /// <summary>
- /// Gets or sets the video encoder tunes.
- /// </summary>
- public List<string> VideoTunes { get; set; }
-
- /// <summary>
- /// Gets or sets the video encoder level.
- /// </summary>
- public string VideoLevel { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether to use QSV decoding.
- /// </summary>
- public bool QsvDecode { get; set; }
-
- /// <summary>
- /// Gets or sets the video encode rate type.
- /// </summary>
- public VideoEncodeRateType VideoEncodeRateType { get; set; }
-
- /// <summary>
- /// Gets or sets the quality.
- /// </summary>
- public double Quality { get; set; }
-
- /// <summary>
- /// Gets or sets the target size.
- /// </summary>
- public int TargetSize { get; set; }
-
- /// <summary>
- /// Gets or sets the video bitrate.
- /// </summary>
- public int VideoBitrate { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether two pass.
- /// </summary>
- public bool TwoPass { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether turbo first pass.
- /// </summary>
- public bool TurboFirstPass { get; set; }
-
- /// <summary>
- /// Gets or sets the framerate.
- /// </summary>
- public double Framerate { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether constant framerate.
- /// </summary>
- public bool ConstantFramerate { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether peak framerate.
- /// </summary>
- public bool PeakFramerate { get; set; }
- #endregion
-
- #region Audio
-
- /// <summary>
- /// Gets or sets the audio encodings.
- /// </summary>
- public List<AudioEncoding> AudioEncodings { get; set; }
-
- /// <summary>
- /// Gets or sets the audio encoder fallback.
- /// </summary>
- public string AudioEncoderFallback { get; set; }
- #endregion
-
- #region Chapter Markers
-
- /// <summary>
- /// Gets or sets a value indicating whether use default chapter names.
- /// </summary>
- public bool UseDefaultChapterNames { get; set; }
-
- /// <summary>
- /// Gets or sets the custom chapter names.
- /// </summary>
- public List<string> CustomChapterNames { get; set; }
- #endregion
-
- #region Subtitles
-
- /// <summary>
- /// Gets or sets the subtitles.
- /// </summary>
- public Subtitles Subtitles { get; set; }
- #endregion
-
- #region Additional Args
-
- /// <summary>
- /// Gets or sets a value indicating whether to use DXVA hardware decoding.
- /// </summary>
- public bool DxvaDecoding { get; set; }
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="EncodeJob"/>.
- /// </returns>
- public EncodeJob Clone()
- {
- var clone = new EncodeJob
- {
- SourceType = this.SourceType,
- SourcePath = this.SourcePath,
- Title = this.Title,
- Angle = this.Angle,
- RangeType = this.RangeType,
- ChapterStart = this.ChapterStart,
- ChapterEnd = this.ChapterEnd,
- SecondsStart = this.SecondsStart,
- SecondsEnd = this.SecondsEnd,
- FramesStart = this.FramesStart,
- FramesEnd = this.FramesEnd,
- Subtitles = this.Subtitles,
- UseDefaultChapterNames = this.UseDefaultChapterNames,
- DxvaDecoding = this.DxvaDecoding,
- OutputPath = this.OutputPath,
-
- ContainerName = this.ContainerName,
- PreferredExtension = this.PreferredExtension,
- IncludeChapterMarkers = this.IncludeChapterMarkers,
- Optimize = this.Optimize,
- IPod5GSupport = this.IPod5GSupport,
-
- Width = this.Width,
- Height = this.Height,
- MaxWidth = this.MaxWidth,
- MaxHeight = this.MaxHeight,
- ScaleMethod = this.ScaleMethod,
- Cropping = this.Cropping.Clone(),
- Anamorphic = this.Anamorphic,
- UseDisplayWidth = this.UseDisplayWidth,
- DisplayWidth = this.DisplayWidth,
- KeepDisplayAspect = this.KeepDisplayAspect,
- PixelAspectX = this.PixelAspectX,
- PixelAspectY = this.PixelAspectY,
- Modulus = this.Modulus,
- Rotation = this.Rotation,
- FlipHorizontal = this.FlipHorizontal,
- FlipVertical = this.FlipVertical,
-
- Deinterlace = this.Deinterlace,
- CustomDeinterlace = this.CustomDeinterlace,
- Decomb = this.Decomb,
- CustomDecomb = this.CustomDecomb,
- Detelecine = this.Detelecine,
- CustomDetelecine = this.CustomDetelecine,
- Denoise = this.Denoise,
- DenoisePreset = this.DenoisePreset,
- DenoiseTune = this.DenoiseTune,
- UseCustomDenoise = this.UseCustomDenoise,
- CustomDenoise = this.CustomDenoise,
- Deblock = this.Deblock,
- Grayscale = this.Grayscale,
-
- VideoEncoder = this.VideoEncoder,
- VideoOptions = this.VideoOptions,
- VideoProfile = this.VideoProfile,
- VideoPreset = this.VideoPreset,
- VideoTunes = this.VideoTunes,
- VideoLevel = this.VideoLevel,
- QsvDecode = this.QsvDecode,
- VideoEncodeRateType = this.VideoEncodeRateType,
- Quality = this.Quality,
- TargetSize = this.TargetSize,
- VideoBitrate = this.VideoBitrate,
- TwoPass = this.TwoPass,
- TurboFirstPass = this.TurboFirstPass,
- Framerate = this.Framerate,
- ConstantFramerate = this.ConstantFramerate,
-
- AudioEncodings = new List<AudioEncoding>(this.AudioEncodings),
- AudioEncoderFallback = this.AudioEncoderFallback
- };
-
- return clone;
- }
-
- #endregion
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncodeRateType.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncodeRateType.cs
deleted file mode 100644
index 4fe209ccb..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncodeRateType.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioEncodeRateType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The audio encode rate type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Encoding
-{
- /// <summary>
- /// The audio encode rate type.
- /// </summary>
- public enum AudioEncodeRateType
- {
- Bitrate,
- Quality,
- Compression
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs
index e8f0a484a..7b18aaa03 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoder.cs
@@ -11,7 +11,7 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding
{
using System.ComponentModel.DataAnnotations;
- using HandBrake.ApplicationServices.Interop.Attributes;
+ using HandBrake.ApplicationServices.Attributes;
/// <summary>
/// The audio encoder.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoding.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoding.cs
deleted file mode 100644
index 96adc79dd..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/AudioEncoding.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioEncoding.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the AudioEncoding type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Encoding
-{
- using System;
-
- /// <summary>
- /// The Audio Encoding Model
- /// </summary>
- public class AudioEncoding
- {
- /// <summary>
- /// Initializes a new instance of the AudioEncoding class.
- /// </summary>
- public AudioEncoding()
- {
- // Initialize to -1 to differentiate a compression of 0 from uninitialized.
- this.Compression = -1;
- }
-
- /// <summary>
- /// Gets or sets the chosen track to apply the encoding to.
- /// </summary>
- /// <remarks>1-based index. 0 means apply to all tracks.</remarks>
- public int InputNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the encoder to use.
- /// </summary>
- public string Encoder { get; set; }
-
- /// <summary>
- /// Gets or sets the encode rate type (bitrate or quality).
- /// </summary>
- public AudioEncodeRateType EncodeRateType { get; set; }
-
- /// <summary>
- /// Gets or sets the bitrate (in kbps) of this track.
- /// </summary>
- public int Bitrate { get; set; }
-
- /// <summary>
- /// Gets or sets the target audio quality for this track.
- /// </summary>
- public float Quality { get; set; }
-
- /// <summary>
- /// Gets or sets the target audio compression for this track.
- /// </summary>
- public float Compression { get; set; }
-
- /// <summary>
- /// Gets or sets the mixdown.
- /// </summary>
- public string Mixdown { get; set; }
-
- /// <summary>
- /// Gets or sets the sample rate in Hz.
- /// </summary>
- public int SampleRateRaw { get; set; }
-
- /// <summary>
- /// Gets or sets Gain.
- /// </summary>
- public int Gain { get; set; }
-
- /// <summary>
- /// Gets or sets Drc.
- /// </summary>
- public double Drc { get; set; }
-
- /// <summary>
- /// Gets or sets Name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether is passthru.
- /// </summary>
- public bool IsPassthru { get; set; }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/VideoEncoder.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/VideoEncoder.cs
index 0752b1277..17ed82aef 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/VideoEncoder.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/VideoEncoder.cs
@@ -11,7 +11,7 @@ namespace HandBrake.ApplicationServices.Interop.Model.Encoding
{
using System.ComponentModel.DataAnnotations;
- using HandBrake.ApplicationServices.Interop.Attributes;
+ using HandBrake.ApplicationServices.Attributes;
/// <summary>
/// The video encoder.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/OutputExtension.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs
index 5154eb58e..ca5a29416 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/OutputExtension.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs
@@ -1,20 +1,20 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="OutputExtension.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="PreviewSettings.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
-// Defines the OutputExtension type.
+// The preview settings.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Model.Encoding
+namespace HandBrake.ApplicationServices.Interop.Model.Preview
{
+ using HandBrake.ApplicationServices.Services.Encode.Model;
+
/// <summary>
- /// The output extension.
+ /// The preview settings.
/// </summary>
- public enum OutputExtension
+ public class PreviewSettings : EncodeTask
{
- Mp4,
- M4v
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs
index c41482e88..91cba7a66 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Size.cs
@@ -9,6 +9,8 @@
namespace HandBrake.ApplicationServices.Interop.Model
{
+ using System.Windows.Forms;
+
/// <summary>
/// The size.
/// </summary>
@@ -38,5 +40,23 @@ namespace HandBrake.ApplicationServices.Interop.Model
/// Gets or sets the width.
/// </summary>
public int Width { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether is empty.
+ /// </summary>
+ public bool IsEmpty
+ {
+ get
+ {
+ if (this.Width <= 0 && this.Height <= 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs
new file mode 100644
index 000000000..65ed3002b
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs
@@ -0,0 +1,60 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SourceVideoInfo.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The source framerate info.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Model
+{
+ /// <summary>
+ /// The source framerate info.
+ /// </summary>
+ public class SourceVideoInfo
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SourceVideoInfo"/> class.
+ /// </summary>
+ /// <param name="framerateNumerator">
+ /// The framerate numerator.
+ /// </param>
+ /// <param name="framerateDenominator">
+ /// The framerate denominator.
+ /// </param>
+ /// <param name="resolution">
+ /// The resolution.
+ /// </param>
+ /// <param name="parVal">
+ /// The par val.
+ /// </param>
+ public SourceVideoInfo(int framerateNumerator, int framerateDenominator, Size resolution, Size parVal)
+ {
+ this.FramerateNumerator = framerateNumerator;
+ this.FramerateDenominator = framerateDenominator;
+ this.Resolution = resolution;
+ this.ParVal = parVal;
+ }
+
+ /// <summary>
+ /// Gets the framerate numerator.
+ /// </summary>
+ public int FramerateNumerator { get; private set; }
+
+ /// <summary>
+ /// Gets the framerate denominator.
+ /// </summary>
+ public int FramerateDenominator { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the resolution (width/height) of this Title
+ /// </summary>
+ public Size Resolution { get; set; }
+
+ /// <summary>
+ /// Gets or sets the pixel aspect ratio.
+ /// </summary>
+ public Size ParVal { get; set; }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/SrtSubtitle.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/SrtSubtitle.cs
deleted file mode 100644
index c81c07ea5..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/SrtSubtitle.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SrtSubtitle.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the SrtSubtitle type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model
-{
- /// <summary>
- /// The srt subtitle.
- /// </summary>
- public class SrtSubtitle
- {
- /// <summary>
- /// Gets or sets the character code.
- /// </summary>
- public string CharacterCode { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the subtitle track should be marked as default.
- /// </summary>
- public bool Default { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the subtitle track should be burned in.
- /// </summary>
- public bool BurnedIn { get; set; }
-
- /// <summary>
- /// Gets or sets the file name.
- /// </summary>
- public string FileName { get; set; }
-
- /// <summary>
- /// Gets or sets the language code.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets the offset.
- /// </summary>
- public int Offset { get; set; }
-
- /// <summary>
- /// The clone.
- /// </summary>
- /// <returns>
- /// The <see cref="SrtSubtitle"/>.
- /// </returns>
- public SrtSubtitle Clone()
- {
- return new SrtSubtitle
- {
- Default = this.Default,
- BurnedIn = this.BurnedIn,
- FileName = this.FileName,
- LanguageCode = this.LanguageCode,
- CharacterCode = this.CharacterCode,
- Offset = this.Offset
- };
- }
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Subtitles.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Subtitles.cs
deleted file mode 100644
index c455ee6a6..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Subtitles.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Subtitles.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the Subtitles type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model
-{
- using System.Collections.Generic;
-
- /// <summary>
- /// The subtitles.
- /// </summary>
- public class Subtitles
- {
- /// <summary>
- /// Gets or sets the source subtitles.
- /// </summary>
- public List<SourceSubtitle> SourceSubtitles { get; set; }
-
- /// <summary>
- /// Gets or sets the srt subtitles.
- /// </summary>
- public List<SrtSubtitle> SrtSubtitles { get; set; }
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoRangeType.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoRangeType.cs
deleted file mode 100644
index 3b38de793..000000000
--- a/win/CS/HandBrake.ApplicationServices/Interop/Model/VideoRangeType.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VideoRangeType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the VideoRangeType type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model
-{
- using System.ComponentModel.DataAnnotations;
-
- /// <summary>
- /// The video range type.
- /// </summary>
- public enum VideoRangeType
- {
- /// <summary>
- /// The entire title.
- /// </summary>
- [Display(Name = "Preview")]
- Preview,
-
- /// <summary>
- /// A chapter range.
- /// </summary>
- [Display(Name = "Chapters")]
- Chapters,
-
- /// <summary>
- /// A timespan range in seconds.
- /// </summary>
- [Display(Name = "Seconds")]
- Seconds,
-
- /// <summary>
- /// A frame range.
- /// </summary>
- [Display(Name = "Frames")]
- Frames
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
index 083e60884..31900ada1 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Factories/EncodeFactory.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs
@@ -7,23 +7,26 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-namespace HandBrake.ApplicationServices.Interop.Json.Factories
+namespace HandBrake.ApplicationServices.Services.Encode.Factories
{
using System;
using System.Collections.Generic;
- using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
- using System.Windows.Media.Animation;
+ using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
using HandBrake.ApplicationServices.Interop.Json.Encode;
+ using HandBrake.ApplicationServices.Interop.Json.Factories;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Encode.Model;
+ using HandBrake.ApplicationServices.Services.Encode.Model.Models;
+ using AudioTrack = HandBrake.ApplicationServices.Services.Encode.Model.Models.AudioTrack;
using Subtitle = HandBrake.ApplicationServices.Interop.Json.Encode.Subtitle;
/// <summary>
@@ -47,10 +50,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <param name="title">
/// The title.
/// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
/// <returns>
/// The <see cref="JsonEncodeObject"/>.
/// </returns>
- internal static JsonEncodeObject Create(EncodeJob job, Title title)
+ internal static JsonEncodeObject Create(EncodeTask job, SourceVideoInfo title, HBConfiguration configuration)
{
JsonEncodeObject encode = new JsonEncodeObject
{
@@ -59,8 +65,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
Destination = CreateDestination(job),
Filter = CreateFilter(job, title),
PAR = CreatePAR(job, title),
- MetaData = CreateMetaData(job),
- Source = CreateSource(job),
+ MetaData = CreateMetaData(job),
+ Source = CreateSource(job, configuration),
Subtitle = CreateSubtitle(job),
Video = CreateVideo(job)
};
@@ -74,30 +80,33 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <param name="job">
/// The job.
/// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
/// <returns>
/// The <see cref="Source"/>.
/// </returns>
- private static Source CreateSource(EncodeJob job)
+ private static Source CreateSource(EncodeTask job, HBConfiguration configuration)
{
Range range = new Range();
- switch (job.RangeType)
+ switch (job.PointToPointMode)
{
- case VideoRangeType.Chapters:
- range.ChapterEnd = job.ChapterEnd;
- range.ChapterStart = job.ChapterStart;
+ case PointToPointMode.Chapters:
+ range.ChapterEnd = job.EndPoint;
+ range.ChapterStart = job.StartPoint;
break;
- case VideoRangeType.Seconds:
- range.PtsToStart = (int)(job.SecondsStart * 90000);
- range.PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000);
+ case PointToPointMode.Seconds:
+ range.PtsToStart = job.StartPoint * 90000;
+ range.PtsToStop = (job.EndPoint - job.StartPoint) * 90000;
break;
- case VideoRangeType.Frames:
- range.FrameToStart = job.FramesStart;
- range.FrameToStop = job.FramesEnd;
+ case PointToPointMode.Frames:
+ range.FrameToStart = job.StartPoint;
+ range.FrameToStop = job.EndPoint;
break;
- case VideoRangeType.Preview:
- range.StartAtPreview = job.StartAtPreview;
- range.SeekPoints = job.SeekPoints;
- range.PtsToStop = job.SecondsEnd * 90000;
+ case PointToPointMode.Preview:
+ range.StartAtPreview = job.PreviewEncodeStartAt;
+ range.SeekPoints = configuration.PreviewScanCount;
+ range.PtsToStop = job.PreviewEncodeDuration * 90000;
break;
}
@@ -119,26 +128,26 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="Destination"/>.
/// </returns>
- private static Destination CreateDestination(EncodeJob job)
+ private static Destination CreateDestination(EncodeTask job)
{
Destination destination = new Destination
{
- File = job.OutputPath,
+ File = job.Destination,
Mp4Options = new Mp4Options
{
IpodAtom = job.IPod5GSupport,
- Mp4Optimize = job.Optimize
+ Mp4Optimize = job.OptimizeMP4
},
- ChapterMarkers = job.IncludeChapterMarkers,
- Mux = HBFunctions.hb_container_get_from_name(job.ContainerName),
+ ChapterMarkers = job.IncludeChapterMarkers,
+ Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up.
ChapterList = new List<ChapterList>()
};
- if (job.UseDefaultChapterNames)
+ if (job.IncludeChapterMarkers)
{
- foreach (string item in job.CustomChapterNames)
+ foreach (ChapterMarker item in job.ChapterNames)
{
- ChapterList chapter = new ChapterList { Name = item };
+ ChapterList chapter = new ChapterList { Name = item.ChapterName };
destination.ChapterList.Add(chapter);
}
}
@@ -158,7 +167,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The produced PAR object.
/// </returns>
- private static PAR CreatePAR(EncodeJob job, Title title)
+ private static PAR CreatePAR(EncodeTask job, SourceVideoInfo title)
{
Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, title, AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH);
return new PAR { Num = resultGeometry.PAR.Num, Den = resultGeometry.PAR.Den };
@@ -171,9 +180,9 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// The job.
/// </param>
/// <returns>
- /// The <see cref="Encode.Subtitle"/>.
+ /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Encode.Subtitle"/>.
/// </returns>
- private static Subtitle CreateSubtitle(EncodeJob job)
+ private static Subtitle CreateSubtitle(EncodeTask job)
{
Subtitle subtitle = new Subtitle
{
@@ -188,41 +197,43 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
SubtitleList = new List<SubtitleList>()
};
- foreach (SourceSubtitle item in job.Subtitles.SourceSubtitles)
+ foreach (SubtitleTrack item in job.SubtitleTracks)
{
- // Handle Foreign Audio Search
- if (item.TrackNumber == 0)
+ if (!item.IsSrtSubtitle)
{
- subtitle.Search.Enable = true;
- subtitle.Search.Burn = item.BurnedIn;
- subtitle.Search.Default = item.Default;
- subtitle.Search.Forced = item.Forced;
+ // Handle Foreign Audio Search
+ if (item.SourceTrack.TrackNumber == 0)
+ {
+ subtitle.Search.Enable = true;
+ subtitle.Search.Burn = item.Burned;
+ subtitle.Search.Default = item.Default;
+ subtitle.Search.Forced = item.Forced;
+ }
+ else
+ {
+ SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Force = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) };
+ subtitle.SubtitleList.Add(track);
+ }
}
else
{
- SubtitleList track = new SubtitleList { Burn = item.BurnedIn, Default = item.Default, Force = item.Forced, ID = item.TrackNumber, Track = (item.TrackNumber - 1) };
- subtitle.SubtitleList.Add(track);
- }
- }
-
- foreach (SrtSubtitle item in job.Subtitles.SrtSubtitles)
- {
- SubtitleList track = new SubtitleList
+ SubtitleList track = new SubtitleList
{
Track = -1, // Indicates SRT
- Default = item.Default,
- Offset = item.Offset,
- Burn = item.BurnedIn,
+ Default = item.Default,
+ Offset = item.SrtOffset,
+ Burn = item.Burned,
SRT =
new SRT
- {
- Filename = item.FileName,
- Codeset = item.CharacterCode,
- Language = item.LanguageCode
- }
+ {
+ Filename = item.SrtPath,
+ Codeset = item.SrtCharCode,
+ Language = item.SrtLang
+ }
};
- subtitle.SubtitleList.Add(track);
+ subtitle.SubtitleList.Add(track);
+ }
}
return subtitle;
@@ -237,27 +248,28 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="Video"/>.
/// </returns>
- private static Video CreateVideo(EncodeJob job)
+ private static Video CreateVideo(EncodeTask job)
{
Video video = new Video();
- HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == job.VideoEncoder);
+ HBVideoEncoder videoEncoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(e => e.ShortName == ApplicationServices.Utilities.Converters.GetVideoEncoder(job.VideoEncoder));
Validate.NotNull(videoEncoder, "Video encoder " + job.VideoEncoder + " not recognized.");
if (videoEncoder != null)
{
video.Codec = videoEncoder.Id;
}
- if (!string.IsNullOrEmpty(job.AdvancedOptions))
+ string advancedOptions = job.ShowAdvancedTab ? job.AdvancedEncoderOptions : string.Empty;
+ if (!string.IsNullOrEmpty(advancedOptions))
{
- video.Options = job.AdvancedOptions;
+ video.Options = advancedOptions;
}
else
{
- video.Level = job.VideoLevel;
- video.Options = job.VideoOptions;
- video.Preset = job.VideoPreset;
- video.Profile = job.VideoProfile;
+ video.Level = job.VideoLevel.ShortName;
+ video.Options = job.ExtraAdvancedArguments;
+ video.Preset = job.VideoPreset.ShortName;
+ video.Profile = job.VideoProfile.ShortName;
}
if (job.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) video.Quality = job.Quality;
@@ -285,56 +297,58 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="Audio"/>.
/// </returns>
- private static Audio CreateAudio(EncodeJob job)
+ private static Audio CreateAudio(EncodeTask job)
{
Audio audio = new Audio();
- if (!string.IsNullOrEmpty(job.AudioEncoderFallback))
- {
- HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(job.AudioEncoderFallback);
- Validate.NotNull(audioEncoder, "Unrecognized fallback audio encoder: " + job.AudioEncoderFallback);
- audio.FallbackEncoder = audioEncoder.Id;
- }
+ // TODO Handled on the front-end ? Maybe we can offload logic.
+ //if (!string.IsNullOrEmpty(job.AudioEncoderFallback))
+ //{
+ // HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(job.AudioEncoderFallback);
+ // Validate.NotNull(audioEncoder, "Unrecognized fallback audio encoder: " + job.AudioEncoderFallback);
+ // audio.FallbackEncoder = audioEncoder.Id;
+ //}
audio.CopyMask = (int)NativeConstants.HB_ACODEC_ANY;
audio.AudioList = new List<AudioList>();
- foreach (AudioEncoding item in job.AudioEncodings)
+ foreach (AudioTrack item in job.AudioTracks)
{
- HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(item.Encoder);
+ HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder) );
Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.Mixdown);
- Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.Mixdown);
+ HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
+ Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
AudioList audioTrack = new AudioList
{
- Track = item.InputNumber - 1,
- DRC = item.Drc,
+ Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
+ DRC = item.DRC,
Encoder = encoder.Id,
Gain = item.Gain,
Mixdown = mixdown.Id,
- NormalizeMixLevel = false,
- Samplerate = item.SampleRateRaw,
- Name = item.Name,
+ NormalizeMixLevel = false,
+ Samplerate = GetSampleRateRaw(item.SampleRate),
+ Name = item.TrackName,
};
if (!item.IsPassthru)
{
- if (item.EncodeRateType == AudioEncodeRateType.Quality)
- {
- audioTrack.Quality = item.Quality;
- }
-
- if (item.EncodeRateType == AudioEncodeRateType.Compression)
- {
- audioTrack.CompressionLevel = item.Compression;
- }
-
- if (item.EncodeRateType == AudioEncodeRateType.Bitrate)
- {
+ // TODO Impiment Quality and Compression. We only support bitrate right now.
+ //if (item.EncodeRateType == AudioEncodeRateType.Quality)
+ //{
+ // audioTrack.Quality = item.Quality;
+ //}
+
+ //if (item.EncodeRateType == AudioEncodeRateType.Compression)
+ //{
+ // audioTrack.CompressionLevel = item.Compression;
+ //}
+
+ //if (item.EncodeRateType == AudioEncodeRateType.Bitrate)
+ // {
audioTrack.Bitrate = item.Bitrate;
- }
+ // }
}
audio.AudioList.Add(audioTrack);
@@ -344,6 +358,28 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
}
/// <summary>
+ /// The get sample rate raw.
+ /// </summary>
+ /// <param name="rate">
+ /// The rate.
+ /// </param>
+ /// <returns>
+ /// The <see cref="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;
+ }
+
+ /// <summary>
/// The create filter.
/// </summary>
/// <param name="job">
@@ -355,7 +391,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="Filter"/>.
/// </returns>
- private static Filter CreateFilter(EncodeJob job, Title title)
+ private static Filter CreateFilter(EncodeTask job, SourceVideoInfo title)
{
Filter filter = new Filter
{
@@ -421,8 +457,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
}
// VFR / CFR
- int fm = job.ConstantFramerate ? 1 : job.PeakFramerate ? 2 : 0;
- IntPtr frameratePrt = Marshal.StringToHGlobalAnsi(job.Framerate.ToString(CultureInfo.InvariantCulture));
+ int fm = job.FramerateMode == FramerateMode.CFR ? 1 : job.FramerateMode == FramerateMode.PFR ? 2 : 0;
+ IntPtr frameratePrt = Marshal.StringToHGlobalAnsi(job.Framerate.ToString()); // TODO check culture
int vrate = HBFunctions.hb_video_framerate_get_from_name(frameratePrt);
int num;
@@ -465,7 +501,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
}
else
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings((int)id, job.DenoisePreset, job.DenoiseTune);
+ IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings((int)id, job.DenoisePreset.ToString().ToLower().Replace(" ", string.Empty), job.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty));
settings = Marshal.PtrToStringAnsi(settingsPtr);
}
@@ -505,7 +541,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Factories
/// <returns>
/// The <see cref="MetaData"/>.
/// </returns>
- private static MetaData CreateMetaData(EncodeJob job)
+ private static MetaData CreateMetaData(EncodeTask job)
{
MetaData metaData = new MetaData();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
index 3dee11f37..8d0391345 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
@@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
using System;
using System.Diagnostics;
using System.Linq;
+ using System.ServiceModel.Channels;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Interfaces;
@@ -21,7 +22,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.Interfaces;
+ using HandBrake.ApplicationServices.Interop.Json.Factories;
using HandBrake.ApplicationServices.Interop.Model;
+ using HandBrake.ApplicationServices.Services.Encode.Factories;
/// <summary>
/// LibHB Implementation of IEncode
@@ -208,9 +211,6 @@ namespace HandBrake.ApplicationServices.Services.Encode
{
ServiceLogMessage("Scan Completed. Setting up the job for encoding ...");
- // Get an EncodeJob object for the Interop Library
- EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);
-
// Start the Encode
Title title = this.scannedSource.Titles.FirstOrDefault(t => t.TitleNumber == job.Task.Title);
if (title == null)
@@ -228,7 +228,10 @@ namespace HandBrake.ApplicationServices.Services.Encode
};
ServiceLogMessage("Starting Encode ...");
- instance.StartEncode(encodeJob, scannedTitle);
+
+ // Get an EncodeJob object for the Interop Library
+ SourceVideoInfo videoInfo = new SourceVideoInfo(title.FramerateNumerator, title.FramerateDenominator, title.Resolution, title.ParVal);
+ instance.StartEncode(EncodeFactory.Create(job.Task, videoInfo, job.Configuration), scannedTitle);
// Fire the Encode Started Event
this.InvokeEncodeStarted(System.EventArgs.Empty);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
index 08ee84b9d..1d5e94299 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
@@ -26,11 +26,11 @@ namespace HandBrake.ApplicationServices.Services.Scan
using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.Interfaces;
using HandBrake.ApplicationServices.Interop.Model;
+ using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Interop.Model.Scan;
using Chapter = HandBrake.ApplicationServices.Services.Scan.Model.Chapter;
using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
- using Size = System.Drawing.Size;
using Subtitle = HandBrake.ApplicationServices.Services.Scan.Model.Subtitle;
using SubtitleType = HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleType;
using Title = HandBrake.ApplicationServices.Services.Scan.Model.Title;
@@ -264,12 +264,10 @@ namespace HandBrake.ApplicationServices.Services.Scan
return null;
}
- EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job, configuraiton);
-
BitmapImage bitmapImage = null;
try
{
- bitmapImage = this.instance.GetPreview(encodeJob, preview);
+ bitmapImage = this.instance.GetPreview((PreviewSettings)job, preview);
}
catch (AccessViolationException e)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs
index 25fb66769..3b6061f77 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Model/Title.cs
@@ -15,8 +15,6 @@ namespace HandBrake.ApplicationServices.Services.Scan.Model
using HandBrake.ApplicationServices.Interop.Model;
- using Size = System.Drawing.Size;
-
/// <summary>
/// An object that represents a single Title of a DVD
/// </summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
index 48df48f8b..72e65adeb 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs
@@ -18,7 +18,7 @@ namespace HandBrake.ApplicationServices.Utilities
using System.Linq;
using System.Reflection;
- using HandBrake.ApplicationServices.Interop.Attributes;
+ using HandBrake.ApplicationServices.Attributes;
/// <summary>
/// Enum Helpers
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
deleted file mode 100644
index a16274694..000000000
--- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="InteropModelCreator.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A Utility Class to Convert a
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
-
- /// <summary>
- /// A Utility Class to Convert a
- /// </summary>
- public class InteropModelCreator
- {
- /// <summary>
- /// The get encode job.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <returns>
- /// The <see cref="EncodeJob"/>.
- /// </returns>
- public static EncodeJob GetEncodeJob(QueueTask task)
- {
- // Sanity Checking
- if (task == null || task.Task == null || task.Configuration == null)
- {
- return null;
- }
-
- return GetEncodeJob(task.Task, task.Configuration);
- }
-
- /// <summary>
- /// Get an EncodeJob model for a LibHB Encode.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// An Interop.EncodeJob model.
- /// </returns>
- public static EncodeJob GetEncodeJob(EncodeTask task, HBConfiguration configuration)
- {
- // The current Job Configuration
- EncodeTask work = task;
-
- // Which will be converted to this EncodeJob Model.
- EncodeJob job = new EncodeJob();
-
- // Audio Settings
- job.AudioEncodings = new List<AudioEncoding>();
- foreach (AudioTrack track in work.AudioTracks)
- {
- AudioEncoding newTrack = new AudioEncoding
- {
- Bitrate = track.Bitrate,
- Drc = track.DRC,
- Gain = track.Gain,
- Encoder = Converters.GetCliAudioEncoder(track.Encoder),
- InputNumber = track.Track.HasValue ? track.Track.Value : 0,
- Mixdown = Converters.GetCliMixDown(track.MixDown),
- SampleRateRaw = GetSampleRateRaw(track.SampleRate),
- EncodeRateType = AudioEncodeRateType.Bitrate,
- Name = track.TrackName,
- IsPassthru = track.IsPassthru,
- };
-
- job.AudioEncodings.Add(newTrack);
- }
-
- // 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;
- case PointToPointMode.Preview:
- job.RangeType = VideoRangeType.Preview;
- 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;
- }
-
- if (work.PointToPointMode == PointToPointMode.Preview)
- {
- job.StartAtPreview = work.PreviewEncodeStartAt.HasValue ? work.PreviewEncodeStartAt.Value + 1 : 1;
- job.SecondsEnd = work.PreviewEncodeDuration.HasValue ? work.PreviewEncodeDuration.Value : 30;
- job.SeekPoints = configuration.PreviewScanCount;
- }
-
- job.Angle = work.Angle;
-
- // Output Settings
- job.IPod5GSupport = work.IPod5GSupport;
- job.Optimize = work.OptimizeMP4;
- switch (work.OutputFormat)
- {
- case OutputFormat.Mp4:
- job.ContainerName = "av_mp4"; // TODO make part of enum.
- break;
- case OutputFormat.Mkv:
- job.ContainerName = "av_mkv"; // TODO make part of enum.
- break;
- }
-
- // Picture Settings
- job.Anamorphic = work.Anamorphic;
- job.Cropping = new Cropping { Top = work.Cropping.Top, Bottom = work.Cropping.Bottom, Left = work.Cropping.Left, Right = work.Cropping.Right };
- job.DisplayWidth = work.DisplayWidth.HasValue ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString()) : 0;
- job.PixelAspectX = work.PixelAspectX;
- job.PixelAspectY = work.PixelAspectY;
- job.Height = work.Height.HasValue ? work.Height.Value : 0;
- job.KeepDisplayAspect = work.KeepDisplayAspect;
- job.MaxHeight = work.MaxHeight.HasValue ? work.MaxHeight.Value : 0;
- job.MaxWidth = work.MaxWidth.HasValue ? work.MaxWidth.Value : 0;
- job.Modulus = work.Modulus.HasValue ? work.Modulus.Value : 16;
- job.UseDisplayWidth = true;
- job.Width = work.Width.HasValue ? work.Width.Value : 0;
-
- // Filter Settings
- job.CustomDecomb = work.CustomDecomb;
- job.CustomDeinterlace = work.CustomDeinterlace;
- job.CustomDenoise = work.CustomDenoise;
- job.DenoisePreset = work.DenoisePreset.ToString().ToLower().Replace(" ", string.Empty);
- job.DenoiseTune = work.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty);
- job.CustomDetelecine = work.CustomDetelecine;
- if (work.Deblock > 4)
- {
- job.Deblock = work.Deblock;
- }
- job.Decomb = work.Decomb;
- job.Deinterlace = work.Deinterlace;
- job.Denoise = work.Denoise;
- job.Detelecine = work.Detelecine;
- job.Grayscale = work.Grayscale;
-
- // Video Settings
- job.Framerate = work.Framerate.HasValue ? work.Framerate.Value : 0;
- job.ConstantFramerate = work.FramerateMode == FramerateMode.CFR;
- job.PeakFramerate = work.FramerateMode == FramerateMode.PFR;
- job.Quality = work.Quality.HasValue ? work.Quality.Value : 0;
- job.VideoBitrate = work.VideoBitrate.HasValue ? work.VideoBitrate.Value : 0;
- job.VideoEncodeRateType = work.VideoEncodeRateType;
- job.VideoEncoder = Converters.GetVideoEncoder(work.VideoEncoder);
- job.TwoPass = work.TwoPass;
- job.TurboFirstPass = work.TurboFirstPass;
-
- if (work.VideoEncoder == VideoEncoder.X264 || work.VideoEncoder == VideoEncoder.X265 || work.VideoEncoder == VideoEncoder.QuickSync)
- {
- job.VideoPreset = work.VideoPreset.ShortName;
- job.VideoProfile = work.VideoProfile.ShortName;
- job.VideoLevel = work.VideoLevel.ShortName;
-
- if (work.VideoEncoder != VideoEncoder.QuickSync)
- {
- job.VideoTunes = new List<string>();
- foreach (var item in work.VideoTunes)
- {
- job.VideoTunes.Add(item.ShortName);
- }
- }
- }
-
- // Chapter Markers
- job.IncludeChapterMarkers = work.IncludeChapterMarkers;
- job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
- job.UseDefaultChapterNames = work.IncludeChapterMarkers;
-
- // Advanced Settings
- job.VideoOptions = work.ExtraAdvancedArguments;
- job.AdvancedOptions = work.ShowAdvancedTab ? work.AdvancedEncoderOptions : string.Empty;
-
- // Subtitles
- job.Subtitles = new Subtitles { SourceSubtitles = new List<SourceSubtitle>(), SrtSubtitles = new List<SrtSubtitle>() };
- foreach (SubtitleTrack track in work.SubtitleTracks)
- {
- if (track.IsSrtSubtitle)
- {
- job.Subtitles.SrtSubtitles.Add(
- new SrtSubtitle
- {
- CharacterCode = track.SrtCharCode,
- Default = track.Default,
- FileName = track.SrtPath,
- LanguageCode = track.SrtLang,
- Offset = track.SrtOffset,
- BurnedIn = track.Burned
- });
- }
- else
- {
- if (track.SourceTrack != null)
- {
- job.Subtitles.SourceSubtitles.Add(
- new SourceSubtitle { BurnedIn = track.Burned, Default = track.Default, Forced = track.Forced, TrackNumber = track.SourceTrack.TrackNumber });
- }
- }
- }
-
- 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;
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
index 4d133606c..24bff58e6 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
@@ -13,7 +13,6 @@ namespace HandBrakeWPF.ViewModels
using System.Collections.Generic;
using System.Globalization;
- using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Services.Scan.Model;
using HandBrake.ApplicationServices.Interop.Model;
@@ -25,7 +24,6 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.ViewModels.Interfaces;
using PresetPictureSettingsMode = HandBrakeWPF.Model.Picture.PresetPictureSettingsMode;
- using Size = System.Drawing.Size;
/// <summary>
/// The Picture Settings View Model
@@ -126,6 +124,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public PictureSettingsViewModel()
{
+ this.sourceResolution = new Size(0, 0);
this.Task = new EncodeTask();
this.Init();
}
@@ -947,7 +946,7 @@ namespace HandBrakeWPF.ViewModels
// Step 3, Set the display width label to indicate the output.
double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);
- this.DisplaySize = this.sourceResolution.IsEmpty
+ this.DisplaySize = this.sourceResolution == null || this.sourceResolution.IsEmpty
? string.Empty
: string.Format("Storage: {0}x{1}, Display: {2}x{3}", result.OutputWidth, result.OutputHeight, dispWidth, result.OutputHeight);