/// <summary> /// The calculate bitrate limits. /// </summary> private void SetupBitrateLimits() { // Base set of bitrates available. List <int> audioBitrates = HandBrakeEncoderHelpers.AudioBitrates; // Defaults int max = 256; int low = 32; // Based on the users settings, find the high and low bitrates. HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.Encoder)); HBRate rate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(t => t.Name == this.SampleRate.ToString(CultureInfo.InvariantCulture)); HBMixdown mixdown = this.mixDown ?? HandBrakeEncoderHelpers.GetMixdown("dpl2"); BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown); if (limits != null) { max = limits.High; low = limits.Low; } // Return the subset of available bitrates. List <int> subsetBitrates = audioBitrates.Where(b => b <= max && b >= low).ToList(); this.bitrates = subsetBitrates; this.NotifyOfPropertyChange(() => this.Bitrates); // If the subset does not contain the current bitrate, request the default. if (!subsetBitrates.Contains(this.Bitrate)) { this.Bitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(hbaenc, rate != null ? rate.Rate : 48000, mixdown); } }
private bool IsPresetDisabled(Preset preset) { bool isQsvEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding); bool isNvencEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder); bool isVcnEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder); HBVideoEncoder foundEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(EnumHelper <VideoEncoder> .GetShortName(preset.Task.VideoEncoder)); if (foundEncoder == null) { return(true); } if (VideoEncoderHelpers.IsQuickSync(preset.Task.VideoEncoder) && !isQsvEnabled) { return(true); } if (VideoEncoderHelpers.IsNVEnc(preset.Task.VideoEncoder) && !isNvencEnabled) { return(true); } if (VideoEncoderHelpers.IsVCN(preset.Task.VideoEncoder) && !isVcnEnabled) { return(true); } return(false); }
/// <summary> /// Converts a value. /// </summary> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> /// <param name="value">The value produced by the binding source.</param><param name="targetType">The type of the binding target property.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { AudioTrack track = value as AudioTrack; if (track != null && track.ScannedTrack != null) { HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder)); BindingList <HBMixdown> mixdowns = new BindingList <HBMixdown>(); foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) { if (HandBrakeEncoderHelpers.MixdownIsSupported( mixdown, encoder, track.ScannedTrack.ChannelLayout)) { mixdowns.Add(mixdown); } } return(mixdowns); } return(value); }
/// <summary> /// The setup quality compression limits. /// </summary> private void SetupQualityCompressionLimits() { HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.Encoder)); if (hbAudioEncoder.SupportsQuality) { RangeLimits limits = null; if (hbAudioEncoder.SupportsQuality) { limits = hbAudioEncoder.QualityLimits; } if (limits != null) { double value = limits.Ascending ? limits.Low : limits.High; List <double> values = new List <double> { value }; if (limits.Ascending) { while (value < limits.High) { value += limits.Granularity; values.Add(value); } } else { while (value > limits.Low) { value -= limits.Granularity; values.Add(value); } } this.encoderQualityValues = values; } else { this.encoderQualityValues = new List <double>(); } } else { this.encoderQualityValues = new List <double>(); } // Default the audio quality value if it's out of range. if (Equals(this.EncoderRateType, AudioEncoderRateType.Quality)) { if (this.Quality.HasValue && !this.encoderQualityValues.Contains(this.Quality.Value)) { this.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(hbAudioEncoder); } } this.NotifyOfPropertyChange(() => this.EncoderQualityValues); }
public void Init() { this.maxAllowedInstances = this.userSettingService.GetUserSetting <int>(UserSettingConstants.SimultaneousEncodes); // Allow QSV adapter scaling. this.qsvGpus = HandBrakeEncoderHelpers.GetQsvAdaptorList(); this.totalQsvInstances = this.qsvGpus.Count * 2; // Allow two instances per GPU if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncHyperEncode)) { // When HyperEncode is supported, we encode 1 job across multiple media engines. this.totalQsvInstances = 1; } // Most Nvidia cards support 3 instances. this.totalNvidiaInstances = 3; // VCE Support still TBD this.totalVceInstances = 3; this.totalMfInstances = 1; // Whether using hardware or not, some CPU is needed so don't allow more jobs than CPU. if (this.maxAllowedInstances > Utilities.SystemInfo.MaximumSimultaneousInstancesSupported) { this.maxAllowedInstances = Utilities.SystemInfo.MaximumSimultaneousInstancesSupported; } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null || values.Length != 2) { return(null); } IList <AudioEncoderRateType> fetchRateTypes = EnumHelper <AudioEncoderRateType> .GetEnumList().ToList(); List <string> types = new List <string>(); foreach (var item in fetchRateTypes) { types.Add(EnumHelper <AudioEncoderRateType> .GetDisplay(item)); } AudioEncoder audioEncoder = values[0] is AudioEncoder ? (AudioEncoder)values[0] : AudioEncoder.None; AudioEncoder fallbackEncoder = values[1] is AudioEncoder ? (AudioEncoder)values[1] : AudioEncoder.None; HBAudioEncoder selectedEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(audioEncoder)); HBAudioEncoder selectedFallbackEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(fallbackEncoder)); if (selectedEncoder != null && selectedEncoder.IsPassthrough) { if (selectedFallbackEncoder != null && !selectedFallbackEncoder.SupportsQuality) { types.Remove(EnumHelper <AudioEncoderRateType> .GetDisplay(AudioEncoderRateType.Quality)); } } return(types); }
/// <summary> /// Restrict the available mixdowns to those that the enocder actually supports. /// </summary> private void SetupMixdowns() { this.mixdowns = new BindingList <HBMixdown>(HandBrakeEncoderHelpers.Mixdowns.ToList()); HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.Encoder)); BindingList <HBMixdown> mixdownList = new BindingList <HBMixdown>(); foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) { if (HandBrakeEncoderHelpers.MixdownHasCodecSupport(mixdown, audioEncoder) || this.IsPassthru) // Show only supported, or all for passthru. { mixdownList.Add(mixdown); } } this.mixdowns = new BindingList <HBMixdown>(mixdownList); this.NotifyOfPropertyChange(() => this.Mixdowns); // If the mixdown isn't supported, downgrade it to the best available. if (!this.Mixdowns.Contains(this.MixDown)) { this.mixDown = this.Mixdowns.LastOrDefault(); this.NotifyOfPropertyChange(() => this.MixDown); } }
private void RefreshCopyMaskChoices() { List <CopyMaskChoiceViewModel> oldChoices = new List <CopyMaskChoiceViewModel>(this.copyMaskChoices.Items); this.copyMaskChoices.Edit(copyMaskChoicesInnerList => { copyMaskChoicesInnerList.Clear(); HBContainer container = HandBrakeEncoderHelpers.GetContainer(this.EncodingWindowViewModel.Profile.ContainerName); foreach (HBAudioEncoder encoder in HandBrakeEncoderHelpers.AudioEncoders) { if ((encoder.CompatibleContainers & container.Id) > 0 && encoder.IsPassthrough && encoder.ShortName != AudioEncodingViewModel.AutoPassthroughEncoder) { bool enabled = true; string codec = encoder.ShortName.Substring(5); CopyMaskChoiceViewModel oldChoice = oldChoices.FirstOrDefault(choice => choice.Codec == codec); if (oldChoice != null) { enabled = oldChoice.Enabled; } copyMaskChoicesInnerList.Add(new CopyMaskChoiceViewModel(codec, enabled)); } } }); }
private string GetAudioDescription() { if (this.Task.AudioTracks.Count == 0) { return(ResourcesUI.SummaryView_NoAudioTracks); } StringBuilder desc = new StringBuilder(); if (this.Task.AudioTracks.Count >= 1) { AudioTrack track1 = this.Task.AudioTracks[0]; HBMixdown mixdownName = HandBrakeEncoderHelpers.GetMixdown(track1.MixDown); string mixdown = mixdownName != null ? ", " + mixdownName.DisplayName : string.Empty; desc.AppendLine(string.Format("{0}{1}", EnumHelper <AudioEncoder> .GetDisplay(track1.Encoder), mixdown)); } if (this.Task.AudioTracks.Count >= 2) { AudioTrack track2 = this.Task.AudioTracks[1]; HBMixdown mixdownName = HandBrakeEncoderHelpers.GetMixdown(track2.MixDown); string mixdown = mixdownName != null ? ", " + mixdownName.DisplayName : string.Empty; desc.AppendLine(string.Format("{0}{1}", EnumHelper <AudioEncoder> .GetDisplay(track2.Encoder), mixdown)); } if (this.Task.AudioTracks.Count > 2) { desc.AppendLine(string.Format("+ {0} {1}", this.Task.AudioTracks.Count - 2, ResourcesUI.SummaryView_AdditionalAudioTracks)); } return(desc.ToString().Trim()); }
public static string GetExtensionForProfile(VCProfile profile, bool includeDot = true) { HBContainer container = HandBrakeEncoderHelpers.GetContainer(profile.ContainerName); if (container == null) { throw new ArgumentException("Could not find container with name " + profile.ContainerName, nameof(profile)); } string extension; if (container.DefaultExtension == "mkv") { extension = "mkv"; } else if (container.DefaultExtension == "mp4" && profile.PreferredExtension == VCOutputExtension.Mp4) { extension = "mp4"; } else { extension = "m4v"; } return(includeDot ? "." + extension : extension); }
/// <summary> /// Initializes a new instance of the <see cref="AudioTrack"/> class. /// Create a track from a behaviour track. /// </summary> /// <param name="track"> /// The Behavior track /// </param> /// <param name="sourceTrack"> /// The source track we are dealing with. /// </param> /// <param name="fallback"> /// An encoder to fall back to. /// </param> public AudioTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback) { AudioEncoder chosenEncoder = track.Encoder; HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder)); if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0) { chosenEncoder = fallback; encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder)); } this.scannedTrack = sourceTrack; this.drc = track.DRC; this.encoder = chosenEncoder; this.gain = track.Gain; this.mixDown = track.MixDown != null ? track.MixDown.ShortName : "dpl2"; // If the mixdown isn't supported, downgrade it. if (track.IsPassthru && track.MixDown != null && encoderInfo != null && !HandBrakeEncoderHelpers.MixdownIsSupported(track.MixDown, encoderInfo, sourceTrack.ChannelLayout)) { HBMixdown changedMixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(encoderInfo, (ulong)sourceTrack.ChannelLayout); if (changedMixdown != null) { this.mixDown = changedMixdown.ShortName; } } this.sampleRate = track.SampleRate; this.encoderRateType = track.EncoderRateType; this.quality = track.Quality; this.bitrate = track.Bitrate; this.SetupLimits(); }
private void RefreshEncoderChoices(string containerName, EncoderChoicesRefreshSource refreshSource) { HBContainer container = HandBrakeEncoderHelpers.GetContainer(containerName); HBVideoEncoder oldEncoder = null; if (this.selectedEncoder != null) { oldEncoder = this.selectedEncoder.Encoder; } this.encoderChoices = new List <VideoEncoderViewModel>(); foreach (HBVideoEncoder encoder in HandBrakeEncoderHelpers.VideoEncoders) { if ((encoder.CompatibleContainers & container.Id) > 0) { this.EncoderChoices.Add(new VideoEncoderViewModel { Encoder = encoder }); } } this.RaisePropertyChanged(nameof(this.EncoderChoices)); HBVideoEncoder targetEncoder; switch (refreshSource) { case EncoderChoicesRefreshSource.ContainerChange: targetEncoder = oldEncoder; break; case EncoderChoicesRefreshSource.ProfileChange: targetEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(this.Profile.VideoEncoder); break; default: throw new ArgumentOutOfRangeException(nameof(refreshSource), refreshSource, null); } this.selectedEncoder = this.EncoderChoices.FirstOrDefault(e => e.Encoder == targetEncoder); if (this.selectedEncoder == null) { this.selectedEncoder = this.EncoderChoices[0]; } // If it's a container change we need to commit the new encoder change. if (refreshSource == EncoderChoicesRefreshSource.ContainerChange && this.selectedEncoder.Encoder != oldEncoder) { this.UpdateProfileProperty(nameof(this.Profile.VideoEncoder), this.selectedEncoder.Encoder.ShortName, raisePropertyChanged: false); this.SetDefaultQuality(); } this.RaisePropertyChanged(nameof(this.SelectedEncoder)); }
/// <summary> /// The create audio. /// </summary> /// <param name="job"> /// The job. /// </param> /// <returns> /// The <see cref="Audio"/>. /// </returns> private static Audio CreateAudio(EncodeJob 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; } audio.CopyMask = (int)NativeConstants.HB_ACODEC_ANY; audio.AudioList = new List <AudioList>(); foreach (AudioEncoding item in job.AudioEncodings) { HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(item.Encoder); Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.Mixdown); Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + item.Mixdown); AudioList audioTrack = new AudioList { Track = item.InputNumber - 1, DRC = item.Drc, Encoder = encoder.Id, Gain = item.Gain, Mixdown = mixdown.Id, NormalizeMixLevel = false, Samplerate = item.SampleRateRaw, Name = item.Name, }; 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) { audioTrack.Bitrate = item.Bitrate; } } audio.AudioList.Add(audioTrack); } return(audio); }
/// <summary> /// Converts a value. /// </summary> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> /// <param name="value">The value produced by the binding source.</param><param name="targetType">The type of the binding target property.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string mixdown = value as string; if (!string.IsNullOrEmpty(mixdown)) { return(HandBrakeEncoderHelpers.GetMixdown(mixdown)); } return(HandBrakeEncoderHelpers.GetMixdown("dpl2")); // Default }
private HBAudioEncoder GetEncoderForLimits() { HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.Encoder)); if (hbaenc != null && hbaenc.IsPassthrough) { hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.fallbackEncoder)); } return(hbaenc); }
public SourceSubtitleViewModel(SubtitleDialogViewModel subtitleDialogViewModel, SourceSubtitle subtitle) { this.SubtitleDialogViewModel = subtitleDialogViewModel; this.subtitle = subtitle; if (subtitle.TrackNumber != 0) { this.inputSubtitle = this.mainViewModel.SelectedTitle.SubtitleList[subtitle.TrackNumber - 1]; } // CanPass this.presetsService.WhenAnyValue(x => x.SelectedPreset.Preset.EncodingProfile.ContainerName, containerName => { if (this.TrackNumber == 0) { return(true); } return(HandBrakeEncoderHelpers.SubtitleCanPassthrough(this.inputSubtitle.Source, HandBrakeEncoderHelpers.GetContainer(containerName).Id)); }).ToProperty(this, x => x.CanPass, out this.canPass); // BurnedInEnabled this.WhenAnyValue(x => x.CanPass, canPass => { if (this.TrackNumber == 0) { return(true); } if (!canPass) { return(false); } if (!this.CanBurn) { return(false); } return(true); }).ToProperty(this, x => x.BurnedInEnabled, out this.burnedInEnabled); // When BurnedInEnabled changes, refresh to see if it should be updated to a predetermined value. this.WhenAnyValue(x => x.BurnedInEnabled).Subscribe(_ => { this.RaisePropertyChanged(nameof(this.BurnedIn)); }); this.DuplicateSubtitle = ReactiveCommand.Create(); this.DuplicateSubtitle.Subscribe(_ => this.DuplicateSubtitleImpl()); this.RemoveSubtitle = ReactiveCommand.Create(); this.RemoveSubtitle.Subscribe(_ => this.RemoveSubtitleImpl()); }
private bool CanAddTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback) { if (fallback == AudioEncoder.None) { HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder)); if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0) { return(false); } } return(true); }
private void RemoveIfNotSupported(AudioEncoder encoder, Audio sourceTrack, List <AudioEncoder> encoders) { if (sourceTrack == null) { return; } HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(encoder)); if ((sourceTrack.Codec & encoderInfo.Id) == 0) { encoders.Remove(encoder); } }
/// <summary> /// Gets the audio encoder to use, given the main encoder choice and the passthrough choice. The generic "Passthrough" choice /// on the main encoder picker is split out into the specific types via the "scope" dropdown. /// </summary> /// <param name="audioEncoderViewModel">The chosen audio encoder.</param> /// <param name="passthrough">The short encoder id of the passthrough option.</param> /// <returns></returns> private static HBAudioEncoder GetHBAudioEncoder(AudioEncoderViewModel audioEncoderViewModel, string passthrough) { if (audioEncoderViewModel == null) { return(null); } if (audioEncoderViewModel.IsPassthrough) { return(HandBrakeEncoderHelpers.GetAudioEncoder(passthrough)); } return(audioEncoderViewModel.Encoder); }
public static OutputAudioTrackInfo GetDefaultSettings(SourceAudioTrack source, HBAudioEncoder encoder) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (encoder == null) { throw new ArgumentNullException(nameof(encoder)); } var result = new OutputAudioTrackInfo { Encoder = encoder, Drc = 0, Gain = 0, SampleRate = HandBrakeEncoderHelpers.SanitizeSampleRate(encoder, source.SampleRate) }; if (encoder.SupportsCompression) { result.CompressionLevel = HandBrakeEncoderHelpers.GetDefaultAudioCompression(encoder); } HBMixdown mixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(encoder, (ulong)source.ChannelLayout); result.Mixdown = mixdown; // For some reason HB does not honor Quality when falling back to an encoder during auto-passthrough. // For now we do bitrate only. //if (encoder.SupportsQuality) //{ // result.EncodeRateType = AudioEncodeRateType.Quality; // result.Quality = HandBrakeEncoderHelpers.GetDefaultQuality(encoder); //} //else //{ result.EncodeRateType = AudioEncodeRateType.Bitrate; result.Bitrate = HandBrakeEncoderHelpers.GetDefaultBitrate(encoder, result.SampleRate, mixdown); //} return(result); }
public void UpdateWarningVisibility() { bool textSubtitleVisible = false; VCProfile profile = this.presetsService.SelectedPreset.Preset.EncodingProfile; HBContainer profileContainer = HandBrakeEncoderHelpers.GetContainer(profile.ContainerName); if (profileContainer.DefaultExtension == "mp4" && profile.PreferredExtension == VCOutputExtension.Mp4) { foreach (SourceSubtitleViewModel sourceVM in this.SourceSubtitles) { if (sourceVM.Selected && sourceVM.SubtitleName.Contains("(Text)")) { textSubtitleVisible = true; break; } } } this.TextSubtitleWarningVisible = textSubtitleVisible; bool anyBurned = false; int totalTracks = 0; foreach (SourceSubtitleViewModel sourceVM in this.SourceSubtitles) { if (sourceVM.Selected) { totalTracks++; if (sourceVM.BurnedIn) { anyBurned = true; } } } foreach (SrtSubtitleViewModel srtVM in this.SrtSubtitles) { totalTracks++; if (srtVM.BurnedIn) { anyBurned = true; } } this.BurnedOverlapWarningVisible = anyBurned && totalTracks > 1; }
private static void UpgradeEncodingProfileTo24(VCProfile profile) { profile.VideoOptions = profile.X264Options; profile.VideoTunes = profile.X264Tunes; profile.VideoPreset = profile.X264Preset; profile.VideoProfile = profile.X264Profile; profile.VideoLevel = profile.H264Level; // If QSV was the old encoder and QSV is available, use the QSV preset. string videoEncoderName = profile.VideoEncoder; if (HandBrakeEncoderHelpers.GetVideoEncoder(videoEncoderName) == null) { if (videoEncoderName == "qsv_h264") { profile.VideoPreset = profile.QsvPreset; } } }
private void RefreshFallbackEncoderChoices() { if (this.EncodingWindowViewModel.Profile == null) { return; } HBContainer container = HandBrakeEncoderHelpers.GetContainer(this.EncodingWindowViewModel.Profile.ContainerName); HBAudioEncoder oldEncoder = null; if (this.audioEncoderFallback != null) { oldEncoder = this.audioEncoderFallback.Encoder; } this.fallbackEncoderChoices = new List <AudioEncoderViewModel>(); this.FallbackEncoderChoices.Add(new AudioEncoderViewModel { Encoder = HandBrakeEncoderHelpers.GetAudioEncoder("none") }); foreach (HBAudioEncoder encoder in HandBrakeEncoderHelpers.AudioEncoders) { if ((encoder.CompatibleContainers & container.Id) > 0 && !encoder.IsPassthrough) { this.FallbackEncoderChoices.Add(new AudioEncoderViewModel { Encoder = encoder }); } } this.RaisePropertyChanged(nameof(this.FallbackEncoderChoices)); this.audioEncoderFallback = this.FallbackEncoderChoices.FirstOrDefault(e => e.Encoder == oldEncoder); if (this.audioEncoderFallback == null) { this.audioEncoderFallback = this.FallbackEncoderChoices[1]; } this.RaisePropertyChanged(nameof(this.AudioEncoderFallback)); }
private void RefreshMixdownChoices() { HBMixdown oldMixdown = null; if (this.SelectedMixdown != null) { oldMixdown = this.SelectedMixdown.Mixdown; } this.mixdownChoices = new List <MixdownViewModel>(); HBAudioEncoder hbAudioEncoder = this.HBAudioEncoder; foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) { // Only add option if codec supports the mixdown if (HandBrakeEncoderHelpers.MixdownHasCodecSupport(mixdown, hbAudioEncoder)) { // Determine compatibility of mixdown with the input channel layout // Incompatible mixdowns are grayed out bool isCompatible = true; if (this.main.HasVideoSource) { SourceAudioTrack track = this.GetTargetAudioTrack(); if (track != null) { isCompatible = HandBrakeEncoderHelpers.MixdownHasRemixSupport(mixdown, (ulong)track.ChannelLayout); } } this.MixdownChoices.Add(new MixdownViewModel { Mixdown = mixdown, IsCompatible = isCompatible }); } } this.RaisePropertyChanged(nameof(this.MixdownChoices)); this.SelectMixdown(oldMixdown); this.RaisePropertyChanged(nameof(this.SelectedMixdown)); }
public void Init() { this.maxAllowedInstances = this.userSettingService.GetUserSetting <int>(UserSettingConstants.SimultaneousEncodes); // Allow QSV adapter scaling. this.qsvGpus = HandBrakeEncoderHelpers.GetQsvAdaptorList(); this.totalQsvInstances = this.qsvGpus.Count * 2; // Allow two instances per GPU // Most Nvidia cards support 3 instances. this.totalNvidiaInstances = 3; // VCE Support still TBD this.totalVceInstances = 3; // Whether using hardware or not, some CPU is needed so don't allow more jobs than CPU. if (this.maxAllowedInstances > Utilities.SystemInfo.GetCpuCoreCount) { this.maxAllowedInstances = Utilities.SystemInfo.GetCpuCoreCount; } }
/// <summary> /// Converts a value. /// </summary> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> /// <param name="value"> /// The value produced by the binding source. /// </param> /// <param name="targetType"> /// The type of the binding target property. /// </param> /// <param name="parameter"> /// The converter parameter to use. /// </param> /// <param name="culture"> /// The culture to use in the converter. /// </param> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { EncodeTask task = value as EncodeTask; if (task != null) { string rfqp = HandBrakeEncoderHelpers.GetVideoQualityRateControlName(EnumHelper <VideoEncoder> .GetShortName(task.VideoEncoder)); string quality = task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality ? string.Format("{0} {1}", task.Quality, rfqp) : string.Format("{0} {1}", task.VideoBitrate, " kbps"); string twoPass = null; if (task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate) { twoPass = task.TwoPass ? task.TurboFirstPass ? " (2-Pass with Turbo)" : " (2-Pass)" : string.Empty; } return(string.Format("{0} - {1}{2}", EnumHelper <VideoEncoder> .GetDisplay(task.VideoEncoder), quality, twoPass)); } return("Unknown"); }
/// <summary> /// Set the default mixdown when the mixdown is null or "none" /// </summary> private void GetDefaultMixdownIfNull() { if (this.ScannedTrack == null) { return; } HBAudioEncoder aencoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(this.encoder)); HBMixdown currentMixdown = HandBrakeEncoderHelpers.GetMixdown(this.mixDown); HBMixdown sanitisedMixdown = HandBrakeEncoderHelpers.SanitizeMixdown(currentMixdown, aencoder, (uint)this.ScannedTrack.ChannelLayout); HBMixdown defaultMixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(aencoder, (uint)this.ScannedTrack.ChannelLayout); if (this.mixDown == null || this.mixDown == "none") { this.MixDown = defaultMixdown.ShortName; } else if (sanitisedMixdown != null) { this.MixDown = sanitisedMixdown.ShortName; } }
/// <summary> /// Initializes a new instance of the <see cref="AudioTrack"/> class. /// Create a track from a behaviour track. /// </summary> /// <param name="track"> /// The Behavior track /// </param> /// <param name="sourceTrack"> /// The source track we are dealing with. /// </param> /// <param name="fallback"> /// An encoder to fall back to. /// </param> public AudioTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback) { AudioEncoder chosenEncoder = track.Encoder; HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder)); if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0) { chosenEncoder = fallback; } this.scannedTrack = sourceTrack; this.drc = track.DRC; this.encoder = chosenEncoder; this.gain = track.Gain; this.mixDown = track.MixDown != null ? track.MixDown.ShortName : "dpl2"; this.sampleRate = track.SampleRate; this.encoderRateType = track.EncoderRateType; this.quality = track.Quality; this.bitrate = track.Bitrate; this.SetupLimits(); }
public static void ErrorCheckEncodingProfile(VCProfile profile) { // mp4v2 only available on x86 string containerName = profile.ContainerName; if (HandBrakeEncoderHelpers.GetContainer(containerName) == null) { if (containerName == "mp4v2") { profile.ContainerName = "av_mp4"; } } // QSV H.264 only available on systems with the right hardware. string videoEncoderName = profile.VideoEncoder; if (HandBrakeEncoderHelpers.GetVideoEncoder(videoEncoderName) == null) { if (videoEncoderName == "qsv_h264") { profile.VideoEncoder = "x264"; } } foreach (var audioEncoding in profile.AudioEncodings) { if (audioEncoding.Encoder == "fdk_aac") { // Make sure this version of VidCoder recognizes the encoder HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(audioEncoding.Encoder); if (encoder == null) { audioEncoding.Encoder = "av_aac"; StaticResolver.Resolve <IAppLogger>().Log("Preset specified fdk_aac but it is not supported in this build of VidCoder. Fell back to av_aac."); } } } }
private static void ErrorCheckPreset(Preset preset) { // mp4v2 only available on x86 string containerName = preset.EncodingProfile.ContainerName; if (HandBrakeEncoderHelpers.GetContainer(containerName) == null) { if (containerName == "mp4v2") { preset.EncodingProfile.ContainerName = "av_mp4"; } } // QSV H.264 only available on systems with the right hardware. string videoEncoderName = preset.EncodingProfile.VideoEncoder; if (HandBrakeEncoderHelpers.GetVideoEncoder(videoEncoderName) == null) { if (videoEncoderName == "qsv_h264") { preset.EncodingProfile.VideoEncoder = "x264"; } } }