/// <summary> /// The hb_set_anamorphic_size_native. /// </summary> /// <param name="job"> /// The job. /// </param> /// <param name="title"> /// The title. /// </param> /// <returns> /// The <see cref="AnamorphicResult"/> object. /// </returns> public static AnamorphicResult hb_set_anamorphic_size(PictureSettingsJob job, PictureSettingsTitle title) { int outputHeight = 0; int outputParHeight = 0; int outputParWidth = 0; int outputWidth = 0; hb_job_s nativeJob = new hb_job_s { modulus = job.Modulus.HasValue ? job.Modulus.Value : 16, anamorphic = new hb_anamorphic_substruct { par_width = job.ParW, par_height = job.ParH, itu_par = 0, mode = (int)job.AnamorphicMode, dar_width = 0, dar_height = 0, keep_display_aspect = job.KeepDisplayAspect ? 1 : 0 }, maxWidth = title.Width, maxHeight = title.Height, keep_ratio = job.KeepDisplayAspect ? 1 : 0, width = job.Width, height = job.Height, crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right } }; hb_title_s title_s = new hb_title_s { crop = new[] { job.Crop.Top, job.Crop.Bottom, job.Crop.Left, job.Crop.Right }, width = title.Width, height = title.Height, pixel_aspect_width = title.ParW, pixel_aspect_height = title.ParH, aspect = 0 }; IntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(hb_title_s))); Marshal.StructureToPtr(title_s, pointer, false); nativeJob.title = pointer; HBFunctions.hb_set_anamorphic_size( ref nativeJob, ref outputWidth, ref outputHeight, ref outputParWidth, ref outputParHeight); return new AnamorphicResult { OutputWidth = outputWidth, OutputHeight = outputHeight, OutputParWidth = outputParWidth, OutputParHeight = outputParHeight }; }
public static extern void hb_get_preview(IntPtr hbHandle, ref hb_title_s title, int preview, IntPtr buffer);
public static extern hb_job_s hb_job_init(ref hb_title_s title);
/// <summary> /// Converts a native title to a Title object. /// </summary> /// <param name="title">The native title structure.</param> /// <returns>The managed Title object.</returns> private Title ConvertTitle(hb_title_s title) { var newTitle = new Title { TitleNumber = title.index, Resolution = new Size(title.width, title.height), ParVal = new Size(title.pixel_aspect_width, title.pixel_aspect_height), Duration = TimeSpan.FromSeconds(title.duration / 90000), AutoCropDimensions = new Cropping { Top = title.crop[0], Bottom = title.crop[1], Left = title.crop[2], Right = title.crop[3] }, AspectRatio = title.aspect, AngleCount = title.angle_count, VideoCodecName = title.video_codec_name, Framerate = ((double)title.rate) / title.rate_base }; switch (title.type) { case hb_title_type_anon.HB_STREAM_TYPE: newTitle.InputType = InputType.Stream; break; case hb_title_type_anon.HB_DVD_TYPE: newTitle.InputType = InputType.Dvd; break; case hb_title_type_anon.HB_BD_TYPE: newTitle.InputType = InputType.Bluray; break; } int currentSubtitleTrack = 1; List<hb_subtitle_s> subtitleList = InteropUtilities.ConvertList<hb_subtitle_s>(title.list_subtitle); foreach (hb_subtitle_s subtitle in subtitleList) { var newSubtitle = new Subtitle { TrackNumber = currentSubtitleTrack, Language = subtitle.lang, LanguageCode = subtitle.iso639_2 }; if (subtitle.format == hb_subtitle_s_subtype.PICTURESUB) { newSubtitle.SubtitleType = SubtitleType.Picture; } else if (subtitle.format == hb_subtitle_s_subtype.TEXTSUB) { newSubtitle.SubtitleType = SubtitleType.Text; } switch (subtitle.source) { case hb_subtitle_s_subsource.CC608SUB: newSubtitle.SubtitleSource = SubtitleSource.CC608; break; case hb_subtitle_s_subsource.CC708SUB: newSubtitle.SubtitleSource = SubtitleSource.CC708; break; case hb_subtitle_s_subsource.SRTSUB: newSubtitle.SubtitleSource = SubtitleSource.SRT; break; case hb_subtitle_s_subsource.SSASUB: newSubtitle.SubtitleSource = SubtitleSource.SSA; break; case hb_subtitle_s_subsource.TX3GSUB: newSubtitle.SubtitleSource = SubtitleSource.TX3G; break; case hb_subtitle_s_subsource.UTF8SUB: newSubtitle.SubtitleSource = SubtitleSource.UTF8; break; case hb_subtitle_s_subsource.VOBSUB: newSubtitle.SubtitleSource = SubtitleSource.VobSub; break; default: break; } newTitle.Subtitles.Add(newSubtitle); currentSubtitleTrack++; } int currentAudioTrack = 1; List<hb_audio_s> audioList = InteropUtilities.ConvertList<hb_audio_s>(title.list_audio); foreach (hb_audio_s audio in audioList) { var newAudio = new AudioTrack { TrackNumber = currentAudioTrack, Codec = Converters.NativeToAudioCodec(audio.config.input.codec), CodecId = audio.config.input.codec, Language = audio.config.lang.simple, LanguageCode = audio.config.lang.iso639_2, Description = audio.config.lang.description, ChannelLayout = audio.config.input.channel_layout, SampleRate = audio.config.input.samplerate, Bitrate = audio.config.input.bitrate }; newTitle.AudioTracks.Add(newAudio); currentAudioTrack++; } List<hb_chapter_s> chapterList = InteropUtilities.ConvertList<hb_chapter_s>(title.list_chapter); foreach (hb_chapter_s chapter in chapterList) { var newChapter = new Chapter { ChapterNumber = chapter.index, Duration = TimeSpan.FromSeconds(((double)chapter.duration) / 90000) }; newTitle.Chapters.Add(newChapter); } return newTitle; }
public static extern hb_job_s hb_job_init(ref hb_title_s title);
public static extern void hb_get_preview(IntPtr hbHandle, ref hb_title_s title, int preview, IntPtr buffer);