diff options
author | sr55 <[email protected]> | 2015-01-02 21:18:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-02 21:18:44 +0000 |
commit | 5381c32a099538cc0e63d5393f26c6aa607b5eee (patch) | |
tree | 1500398a8ce1a229ead477ccc83e95b657e7f2c8 /win/CS/HandBrake.Interop/HandBrakeInterop | |
parent | c919eaba0bdf52a41443e2845e445de9582c5de3 (diff) |
WinGui: Bug fixes to the libhb json encode factory and surrounding classes. Encoding is now working, but some settings are not fully honoured yet.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6681 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop')
5 files changed, 125 insertions, 103 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index a8bf3db75..0ed007e53 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -445,28 +445,46 @@ namespace HandBrake.Interop /// <param name="jobToStart">
/// The job to start.
/// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="scanPreviewCount">
/// The scan Preview Count.
/// </param>
- public void StartEncode(EncodeJob jobToStart, int scanPreviewCount)
+ public void StartEncode(EncodeJob jobToStart, Title title, int scanPreviewCount)
{
- this.StartEncode(jobToStart, false, 0, 0, 0, scanPreviewCount);
+ this.StartEncode(jobToStart, title, false, 0, 0, 0, scanPreviewCount);
}
/// <summary>
/// Starts an encode with the given job.
/// </summary>
- /// <param name="job">The job to start.</param>
- /// <param name="preview">The scan Preview Count.</param>
- /// <param name="previewNumber">Preview Feature: Preview to encode</param>
- /// <param name="previewSeconds">Number of seconds to encode for the preview</param>
- /// <param name="overallSelectedLengthSeconds"></param>
- /// <param name="scanPreviewCount">Number of previews</param>
- public void StartEncode(EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount)
+ /// <param name="job">
+ /// The job to start.
+ /// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="preview">
+ /// The scan Preview Count.
+ /// </param>
+ /// <param name="previewNumber">
+ /// Preview Feature: Preview to encode
+ /// </param>
+ /// <param name="previewSeconds">
+ /// Number of seconds to encode for the preview
+ /// </param>
+ /// <param name="overallSelectedLengthSeconds">
+ /// The overall Selected Length Seconds.
+ /// </param>
+ /// <param name="scanPreviewCount">
+ /// Number of previews
+ /// </param>
+ public void StartEncode(EncodeJob job, Title title, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount)
{
this.previewCount = scanPreviewCount;
- JsonEncodeObject encodeObject = EncodeFactory.Create(job, lastScan);
+ JsonEncodeObject encodeObject = EncodeFactory.Create(job, title);
JsonSerializerSettings settings = new JsonSerializerSettings
{
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs index 64c03cbef..e6eeae943 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs @@ -143,10 +143,13 @@ namespace HandBrake.Interop.Interfaces /// <param name="jobToStart">
/// The job to start.
/// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="scanPreviewCount">
/// The scan Preview Count.
/// </param>
- void StartEncode(EncodeJob jobToStart, int scanPreviewCount);
+ void StartEncode(EncodeJob jobToStart, Title title, int scanPreviewCount);
/// <summary>
/// Starts an encode with the given job.
@@ -154,6 +157,9 @@ namespace HandBrake.Interop.Interfaces /// <param name="job">
/// The job to start.
/// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <param name="preview">
/// True if this is a preview encode.
/// </param>
@@ -170,8 +176,7 @@ namespace HandBrake.Interop.Interfaces /// <param name="scanPreviewCount">
/// The scan Preview Count.
/// </param>
- void StartEncode(
- EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount);
+ void StartEncode(EncodeJob job, Title title, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount);
/// <summary>
/// Starts scanning the given path.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs index cb882c126..598fedac1 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs @@ -21,6 +21,9 @@ namespace HandBrake.Interop.Json.Factories using Newtonsoft.Json;
+ /// <summary>
+ /// The anamorphic factory.
+ /// </summary>
public class AnamorphicFactory
{
/// <summary>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs index fd2274e3f..0c074262d 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs @@ -18,17 +18,11 @@ namespace HandBrake.Interop.Json.Factories using HandBrake.Interop.Helpers;
using HandBrake.Interop.Json.Anamorphic;
using HandBrake.Interop.Json.Encode;
- using HandBrake.Interop.Json.Scan;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Scan;
- using Newtonsoft.Json;
-
- using AudioList = HandBrake.Interop.Json.Encode.AudioList;
- using ChapterList = HandBrake.Interop.Json.Encode.ChapterList;
- using MetaData = HandBrake.Interop.Json.Encode.MetaData;
- using PAR = HandBrake.Interop.Json.Anamorphic.PAR;
- using SubtitleList = HandBrake.Interop.Json.Encode.SubtitleList;
+ using Subtitle = HandBrake.Interop.Json.Encode.Subtitle;
/// <summary>
/// This factory takes the internal EncodeJob object and turns it into a set of JSON models
@@ -36,34 +30,30 @@ namespace HandBrake.Interop.Json.Factories /// </summary>
internal class EncodeFactory
{
-
- /*
- * <j45> maxWidth and maxHeight are frontend issues. You pass those into hb_set_anamorphic_size when calculating geometry settings. width and height are given to the CROP_SCALE filter. No need for the frontend to set it in the job. The job will get the final dimensions from the filter settings anyway.
- * <j45> for example, both crop_scale and rotate filters modify job width and height settings
- *
- */
-
/// <summary>
/// The create.
/// </summary>
/// <param name="job">
/// The encode job.
/// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <returns>
/// The <see cref="JsonEncodeObject"/>.
/// </returns>
- internal static JsonEncodeObject Create(EncodeJob job, JsonScanObject scannedSource)
+ internal static JsonEncodeObject Create(EncodeJob job, Title title)
{
JsonEncodeObject encode = new JsonEncodeObject
{
- SequenceID = 0,
- Audio = CreateAudio(job),
- Destination = CreateDestination(job),
- Filter = CreateFilter(job),
- PAR = CreatePAR(job),
- MetaData = CreateMetaData(job),
- Source = CreateSource(job),
- Subtitle = CreateSubtitle(job),
+ SequenceID = 0,
+ Audio = CreateAudio(job),
+ Destination = CreateDestination(job),
+ Filter = CreateFilter(job, title),
+ PAR = CreatePAR(job),
+ MetaData = CreateMetaData(job),
+ Source = CreateSource(job),
+ Subtitle = CreateSubtitle(job),
Video = CreateVideo(job)
};
@@ -83,17 +73,17 @@ namespace HandBrake.Interop.Json.Factories {
Source source = new Source
{
- Title = job.Title,
+ Title = job.Title,
Range =
new Range
{
- ChapterEnd = job.ChapterEnd,
- ChapterStart = job.ChapterStart,
- FrameToStart = job.FramesStart,
- FrameToStop = job.FramesEnd,
- PtsToStart = (int)(job.SecondsStart * 90000),
- PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000),
- },
+ ChapterEnd = job.ChapterEnd,
+ ChapterStart = job.ChapterStart,
+ FrameToStart = job.FramesStart,
+ FrameToStop = job.FramesEnd,
+ PtsToStart = (int)(job.SecondsStart * 90000),
+ PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000),
+ },
Angle = job.Angle
};
return source;
@@ -112,23 +102,24 @@ namespace HandBrake.Interop.Json.Factories {
Destination destination = new Destination
{
- File = job.OutputPath,
- Mp4Options =
- new Mp4Options
- {
- IpodAtom = job.EncodingProfile.IPod5GSupport,
- // LargeFileSize = job.EncodingProfile.LargeFile,
- Mp4Optimize = job.EncodingProfile.Optimize
- },
- ChapterMarkers = job.EncodingProfile.IncludeChapterMarkers,
- Mux = HBFunctions.hb_container_get_from_name(job.EncodingProfile.ContainerName),
+ File = job.OutputPath,
+ Mp4Options = new Mp4Options
+ {
+ IpodAtom = job.EncodingProfile.IPod5GSupport,
+ Mp4Optimize = job.EncodingProfile.Optimize
+ },
+ ChapterMarkers = job.EncodingProfile.IncludeChapterMarkers,
+ Mux = HBFunctions.hb_container_get_from_name(job.EncodingProfile.ContainerName),
ChapterList = new List<ChapterList>()
};
- foreach (string item in job.CustomChapterNames)
+ if (!job.UseDefaultChapterNames)
{
- ChapterList chapter = new ChapterList { Name = item };
- destination.ChapterList.Add(chapter);
+ foreach (string item in job.CustomChapterNames)
+ {
+ ChapterList chapter = new ChapterList { Name = item };
+ destination.ChapterList.Add(chapter);
+ }
}
return destination;
@@ -137,11 +128,15 @@ namespace HandBrake.Interop.Json.Factories /// <summary>
/// Create the PAR object
/// </summary>
- /// <param name="job">The Job</param>
- /// <returns>The produced PAR object.</returns>
+ /// <param name="job">
+ /// The Job
+ /// </param>
+ /// <returns>
+ /// The produced PAR object.
+ /// </returns>
private static PAR CreatePAR(EncodeJob job)
{
- return new PAR {Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY} ;
+ return new PAR { Num = job.EncodingProfile.PixelAspectX, Den = job.EncodingProfile.PixelAspectY };
}
/// <summary>
@@ -151,7 +146,7 @@ namespace HandBrake.Interop.Json.Factories /// The job.
/// </param>
/// <returns>
- /// The <see cref="Subtitle"/>.
+ /// The <see cref="Encode.Subtitle"/>.
/// </returns>
private static Subtitle CreateSubtitle(EncodeJob job)
{
@@ -160,11 +155,11 @@ namespace HandBrake.Interop.Json.Factories Search =
new Search
{
- Enable = false,
- Default = false,
- Burn = false,
+ Enable = false,
+ Default = false,
+ Burn = false,
Forced = false
- },
+ },
SubtitleList = new List<SubtitleList>()
};
@@ -172,10 +167,10 @@ namespace HandBrake.Interop.Json.Factories {
SubtitleList track = new SubtitleList
{
- Burn = item.BurnedIn,
- Default = item.Default,
- Force = item.Forced,
- ID = item.TrackNumber,
+ Burn = item.BurnedIn,
+ Default = item.Default,
+ Force = item.Forced,
+ ID = item.TrackNumber,
Track = item.TrackNumber
};
@@ -186,13 +181,13 @@ namespace HandBrake.Interop.Json.Factories {
SubtitleList track = new SubtitleList
{
- Default = item.Default,
- Offset = item.Offset,
+ Default = item.Default,
+ Offset = item.Offset,
SRT =
new SRT
{
- Filename = item.FileName,
- Codeset = item.CharacterCode,
+ Filename = item.FileName,
+ Codeset = item.CharacterCode,
Language = item.LanguageCode
}
};
@@ -270,15 +265,15 @@ namespace HandBrake.Interop.Json.Factories AudioList audioTrack = new AudioList
{
- Track = numTracks++,
- Bitrate = item.Bitrate,
- CompressionLevel = item.Compression,
- DRC = item.Drc,
- Encoder = encoder.Id,
- Gain = item.Gain,
- Mixdown = mixdown.Id,
- NormalizeMixLevel = false,
- Quality = item.Quality,
+ Track = numTracks++,
+ Bitrate = item.Bitrate,
+ CompressionLevel = item.Compression,
+ DRC = item.Drc,
+ Encoder = encoder.Id,
+ Gain = item.Gain,
+ Mixdown = mixdown.Id,
+ NormalizeMixLevel = false,
+ Quality = item.Quality,
Samplerate = item.SampleRateRaw
};
@@ -289,19 +284,22 @@ namespace HandBrake.Interop.Json.Factories }
/// <summary>
- /// The create filter. TODO
+ /// The create filter.
/// </summary>
/// <param name="job">
/// The job.
/// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
/// <returns>
/// The <see cref="Filter"/>.
/// </returns>
- private static Filter CreateFilter(EncodeJob job)
+ private static Filter CreateFilter(EncodeJob job, Title title)
{
Filter filter = new Filter
{
- FilterList = new List<FilterList>(),
+ FilterList = new List<FilterList>(),
Grayscale = job.EncodingProfile.Grayscale
};
@@ -315,7 +313,7 @@ namespace HandBrake.Interop.Json.Factories // Decomb
if (job.EncodingProfile.Decomb != Decomb.Off)
{
- string options = "";
+ string options;
if (job.EncodingProfile.Decomb == Decomb.Fast)
{
options = "7:2:6:9:1:80";
@@ -336,7 +334,7 @@ namespace HandBrake.Interop.Json.Factories // Deinterlace
if (job.EncodingProfile.Deinterlace != Deinterlace.Off)
{
- string options = string.Empty;
+ string options;
if (job.EncodingProfile.Deinterlace == Deinterlace.Fast)
{
options = "0";
@@ -362,12 +360,12 @@ namespace HandBrake.Interop.Json.Factories filter.FilterList.Add(filterItem);
}
- // VFR / CFR TODO
+ // VFR / CFR TODO Setup the framerate shaper.
FilterList framerateShaper = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_VFR, Settings = string.Empty };
filter.FilterList.Add(framerateShaper);
// Deblock
- if (job.EncodingProfile.Deblock < 5)
+ if (job.EncodingProfile.Deblock >= 5)
{
FilterList filterItem = new FilterList { ID = (int)hb_filter_ids.HB_FILTER_DEBLOCK, Settings = job.EncodingProfile.Deblock.ToString() };
filter.FilterList.Add(filterItem);
@@ -397,17 +395,19 @@ namespace HandBrake.Interop.Json.Factories }
// CropScale Filter
+ // TODO handle anamorphic.
+ Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, title, AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH);
FilterList cropScale = new FilterList
{
- ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE,
+ ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE,
Settings =
string.Format(
- "{0}:{1}:{2}:{3}:{4}:{5}",
- job.EncodingProfile.Width,
- job.EncodingProfile.Height,
- job.EncodingProfile.Cropping.Top,
- job.EncodingProfile.Cropping.Bottom,
- job.EncodingProfile.Cropping.Left,
+ "{0}:{1}:{2}:{3}:{4}:{5}",
+ resultGeometry.Width,
+ resultGeometry.Height,
+ job.EncodingProfile.Cropping.Top,
+ job.EncodingProfile.Cropping.Bottom,
+ job.EncodingProfile.Cropping.Left,
job.EncodingProfile.Cropping.Right)
};
filter.FilterList.Add(cropScale);
@@ -430,6 +430,8 @@ namespace HandBrake.Interop.Json.Factories private static MetaData CreateMetaData(EncodeJob job)
{
MetaData metaData = new MetaData();
+
+ /* TODO NOT SUPPORTED YET. */
return metaData;
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs index bcabcf282..82cbe55b1 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs @@ -44,11 +44,6 @@ namespace HandBrake.Interop.Model.Encoding public bool IncludeChapterMarkers { get; set; }
/// <summary>
- /// Gets or sets a value indicating whether large file.
- /// </summary>
- public bool LargeFile { get; set; }
-
- /// <summary>
/// Gets or sets a value indicating whether optimize.
/// </summary>
public bool Optimize { get; set; }
@@ -320,7 +315,6 @@ namespace HandBrake.Interop.Model.Encoding ContainerName = this.ContainerName,
PreferredExtension = this.PreferredExtension,
IncludeChapterMarkers = this.IncludeChapterMarkers,
- LargeFile = this.LargeFile,
Optimize = this.Optimize,
IPod5GSupport = this.IPod5GSupport,
|