示例#1
0
        /// <summary>
        /// Initializes a new instance of the NativeList class.
        /// </summary>
        /// <param name="listPtr">The pointer to use for the list.</param>
        public NativeList(IntPtr listPtr)
        {
            this.Ptr = listPtr;
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#2
0
        public IHbFunctions GetHbFunctionsWrapper()
        {
            if (hbFunctions == null)
            {
                hbFunctions = new HbFunctionsDirect();
            }

            return(hbFunctions);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HBVideoEncoder"/> class.
        /// </summary>
        /// <param name="compatibleContainers">
        /// The compatible containers.
        /// </param>
        /// <param name="displayName">
        /// The display name.
        /// </param>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="shortName">
        /// The short name.
        /// </param>
        public HBVideoEncoder(int compatibleContainers, string displayName, int id, string shortName)
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();

            this.CompatibleContainers = compatibleContainers;
            this.DisplayName          = displayName;
            this.Id        = id;
            this.ShortName = shortName;
        }
        /// <summary>
        /// Initializes static members of the HandBrakeEncoderHelpers class.
        /// </summary>
        static HandBrakeEncoderHelpers()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();

            if (!HandBrakeUtils.IsInitialised())
            {
                throw new Exception("Please Initialise with HandBrakeUtils.EnsureGlobalInit before using!");
            }
        }
示例#5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <param name="verbosity">
        /// The code for the logging verbosity to use.
        /// </param>
        /// <param name="noHardware">
        /// True disables hardware init.
        /// </param>
        public void Initialize(int verbosity, bool noHardware)
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();

            HandBrakeUtils.EnsureGlobalInit(noHardware);

            HandBrakeUtils.RegisterLogger();
            this.Handle = hbFunctions.hb_init(verbosity, update_check: 0);
        }
示例#6
0
        /// <summary>
        /// The hb_set_anamorphic_size 2.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="setting">
        /// The setting.
        /// </param>
        /// <returns>
        /// The <see cref="AnamorphicResult"/>.
        /// </returns>
        public static AnamorphicResult hb_set_anamorphic_size2(PictureSettingsJob job, PictureSettingsTitle title, KeepSetting setting)
        {
            int settingMode = (int)setting + (job.KeepDisplayAspect ? 0x04 : 0);

            hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
            {
                crop      = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right },
                itu_par   = 0,
                keep      = settingMode,
                maxWidth  = job.MaxWidth,
                maxHeight = job.MaxHeight,
                mode      = (int)job.AnamorphicMode,
                modulus   = job.Modulus.HasValue ? job.Modulus.Value : 16,
                geometry  = new hb_geometry_s {
                    height = job.Height, width = job.Width, par = job.AnamorphicMode != Anamorphic.Custom ? new hb_rational_t {
                        den = title.ParH, num = title.ParW
                    } : new hb_rational_t {
                        den = job.ParH, num = job.ParW
                    }
                }
            };

            hb_geometry_s sourceGeometry = new hb_geometry_s
            {
                width  = title.Width,
                height = title.Height,
                par    = new hb_rational_t {
                    den = title.ParH, num = title.ParW
                }
            };

            hb_geometry_s result = new hb_geometry_s();

            IHbFunctionsProvider provider    = IoC.Get <IHbFunctionsProvider>(); // TODO make this method non static and remove IoC call.
            IHbFunctions         hbFunctions = provider.GetHbFunctionsWrapper();

            hbFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result);

            int outputWidth     = result.width;
            int outputHeight    = result.height;
            int outputParWidth  = result.par.num;
            int outputParHeight = result.par.den;

            return(new AnamorphicResult {
                OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight
            });
        }
示例#7
0
        /// <summary>
        /// Initializes static members of the HandBrakeUnitConversionHelpers class.
        /// </summary>
        static HandBrakeUnitConversionHelpers()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();

            if (!HandBrakeUtils.IsInitialised())
            {
                throw new Exception("Please Initialise with HandBrakeUtils.EnsureGlobalInit before using!");
            }

            VideoRates = new Dictionary <double, int>();
            foreach (var framerate in HandBrakeEncoderHelpers.VideoFramerates)
            {
                VideoRates.Add(double.Parse(framerate.Name, CultureInfo.InvariantCulture), framerate.Rate);
            }
        }
示例#8
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="job">
        /// The encode job.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        /// <param name="hbFunctionsWrapper">
        /// An instance of IHbFunctions
        /// </param>
        /// <returns>
        /// The <see cref="JsonEncodeObject"/>.
        /// </returns>
        internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration, IHbFunctions hbFunctionsWrapper)
        {
            hbFunctions = hbFunctionsWrapper;

            JsonEncodeObject encode = new JsonEncodeObject
            {
                SequenceID  = 0,
                Audio       = CreateAudio(job),
                Destination = CreateDestination(job),
                Filters     = CreateFilters(job),
                PAR         = CreatePAR(job),
                Metadata    = CreateMetadata(job),
                Source      = CreateSource(job, configuration),
                Subtitle    = CreateSubtitle(job),
                Video       = CreateVideo(job, configuration)
            };

            return(encode);
        }
示例#9
0
        private string GetQueueJson(List <EncodeTask> tasks, HBConfiguration configuration)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
            };

            IHbFunctionsProvider provider    = IoC.Get <IHbFunctionsProvider>(); // TODO remove IoC call.
            IHbFunctions         hbFunctions = provider.GetHbFunctionsWrapper();

            List <Task> queueJobs = new List <Task>();

            foreach (var item in tasks)
            {
                Task task = new Task {
                    Job = this.encodeTaskFactory.Create(item, configuration)
                };
                queueJobs.Add(task);
            }

            return(JsonConvert.SerializeObject(queueJobs, Formatting.Indented, settings));
        }
示例#10
0
        public EncodeTaskFactory(IUserSettingService userSettingService, IHbFunctions hbFunctionsWrapper)
        {
            this.userSettingService = userSettingService;

            this.hbFunctions = hbFunctionsWrapper;
        }
示例#11
0
        static HandBrakeUtils()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#12
0
        static HandBrakeFilterHelpers()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#13
0
        public Title CreateTitle(SourceTitle title, int mainFeature)
        {
            Title converted = new Title
            {
                TitleNumber        = title.Index,
                Duration           = new TimeSpan(0, title.Duration.Hours, title.Duration.Minutes, title.Duration.Seconds),
                Resolution         = new Size(title.Geometry.Width, title.Geometry.Height),
                AngleCount         = title.AngleCount,
                ParVal             = new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den),
                AutoCropDimensions = new Cropping
                {
                    Top    = title.Crop[0],
                    Bottom = title.Crop[1],
                    Left   = title.Crop[2],
                    Right  = title.Crop[3]
                },
                Fps                  = ((double)title.FrameRate.Num) / title.FrameRate.Den,
                SourceName           = title.Path,
                MainTitle            = mainFeature == title.Index,
                Playlist             = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
                FramerateNumerator   = title.FrameRate.Num,
                FramerateDenominator = title.FrameRate.Den,
                Type                 = title.Type
            };

            int currentTrack = 1;

            foreach (SourceChapter chapter in title.ChapterList)
            {
                string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty;
                converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)));
                currentTrack++;
            }

            int currentAudioTrack = 1;

            foreach (SourceAudioTrack track in title.AudioList)
            {
                converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, track.Codec, track.SampleRate, track.BitRate, track.ChannelLayout, track.Name));
                currentAudioTrack++;
            }

            int currentSubtitleTrack = 1;

            foreach (SourceSubtitleTrack track in title.SubtitleList)
            {
                SubtitleType convertedType = new SubtitleType();

                switch (track.Source)
                {
                case (int)hb_subtitle_s_subsource.VOBSUB:
                    convertedType = SubtitleType.VobSub;
                    break;

                case (int)hb_subtitle_s_subsource.CC608SUB:
                case (int)hb_subtitle_s_subsource.CC708SUB:
                    convertedType = SubtitleType.CC;
                    break;

                case (int)hb_subtitle_s_subsource.IMPORTSRT:
                    convertedType = SubtitleType.SRT;
                    break;

                case (int)hb_subtitle_s_subsource.UTF8SUB:
                    convertedType = SubtitleType.UTF8Sub;
                    break;

                case (int)hb_subtitle_s_subsource.TX3GSUB:
                    convertedType = SubtitleType.TX3G;
                    break;

                case (int)hb_subtitle_s_subsource.SSASUB:
                    convertedType = SubtitleType.SSA;
                    break;

                case (int)hb_subtitle_s_subsource.PGSSUB:
                    convertedType = SubtitleType.PGS;
                    break;
                }

                IHbFunctionsProvider provider    = IoC.Get <IHbFunctionsProvider>(); // TODO remove IoC call
                IHbFunctions         hbFunctions = provider.GetHbFunctionsWrapper();

                bool canBurn          = hbFunctions.hb_subtitle_can_burn(track.Source) > 0;
                bool canSetForcedOnly = hbFunctions.hb_subtitle_can_force(track.Source) > 0;

                converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly, track.Name));
                currentSubtitleTrack++;
            }

            SourceMetadata metadata = title.MetaData;

            if (title.MetaData != null)
            {
                converted.Metadata = new Metadata(
                    metadata.AlbumArtist,
                    metadata.Album,
                    metadata.Artist,
                    metadata.Comment,
                    metadata.Composer,
                    metadata.Description,
                    metadata.Genre,
                    metadata.LongDescription,
                    metadata.Name,
                    metadata.ReleaseDate);
            }

            return(converted);
        }
示例#14
0
        static SystemInfo()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#15
0
        static HandBrakePresetService()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#16
0
        static HandBrakeLanguagesHelper()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#17
0
        static InteropUtilities()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }
示例#18
0
        static VersionHelper()
        {
            IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();

            hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
        }