Exemple #1
0
        public AudioTrack(AudioTrack track, bool setScannedTrack)
        {
            this.bitrate    = track.Bitrate;
            this.drc        = track.DRC;
            this.encoder    = track.Encoder;
            this.gain       = track.Gain;
            this.mixDown    = track.MixDown;
            this.sampleRate = track.SampleRate;
            if (setScannedTrack)
            {
                this.scannedTrack = track.ScannedTrack ?? new Audio();
            }

            if (!string.IsNullOrEmpty(this.scannedTrack?.Name))
            {
                this.TrackName = this.scannedTrack.Name;
            }

            if (!string.IsNullOrEmpty(track.TrackName))
            {
                this.TrackName = track.TrackName;
            }

            this.Quality = track.Quality;

            // Setup Backing Properties
            this.encoderRateType = track.EncoderRateType;
            this.SetupLimits();
        }
Exemple #2
0
        /// <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();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AudioTrack"/> class.
 /// Copy Constructor
 /// </summary>
 /// <param name="track">
 /// The track.
 /// </param>
 public AudioBehaviourTrack(AudioBehaviourTrack track)
 {
     this.bitrate = track.Bitrate;
     this.drc = track.DRC;
     this.encoder = track.Encoder;
     this.gain = track.Gain;
     this.mixDown = track.MixDown;
     this.sampleRate = track.SampleRate;
     this.Quality = track.Quality;
     this.encoderRateType = track.EncoderRateType;
     this.SetupLimits();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AudioTrack"/> class.
 /// Copy Constructor
 /// </summary>
 /// <param name="track">
 /// The track.
 /// </param>
 public AudioBehaviourTrack(AudioBehaviourTrack track)
 {
     this.bitrate         = track.Bitrate;
     this.drc             = track.DRC;
     this.encoder         = track.Encoder;
     this.gain            = track.Gain;
     this.mixDown         = track.MixDown;
     this.sampleRate      = track.SampleRate;
     this.Quality         = track.Quality;
     this.encoderRateType = track.EncoderRateType;
     this.SetupLimits();
 }
Exemple #5
0
        public AudioTrack(AudioBehaviourTrack track, Audio sourceTrack, AllowedPassthru fallback, OutputFormat container)
        {
            AudioEncoder   chosenEncoder = track.Encoder;
            HBAudioEncoder encoderInfo   = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(track.Encoder));

            if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0)
            {
                chosenEncoder = fallback.AudioEncoderFallback;
            }

            if (track.IsPassthru && chosenEncoder == AudioEncoder.Passthrough)
            {
                HBAudioEncoder fallbackEncoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(fallback.AudioEncoderFallback));

                if (fallbackEncoderInfo != null)
                {
                    int format   = HandBrakeEncoderHelpers.GetContainer(EnumHelper <OutputFormat> .GetShortName(container)).Id;
                    int copyMask = checked ((int)HandBrakeEncoderHelpers.BuildCopyMask(
                                                fallback.AudioAllowMP2Pass,
                                                fallback.AudioAllowMP3Pass,
                                                fallback.AudioAllowAACPass,
                                                fallback.AudioAllowAC3Pass,
                                                fallback.AudioAllowDTSPass,
                                                fallback.AudioAllowDTSHDPass,
                                                fallback.AudioAllowEAC3Pass,
                                                fallback.AudioAllowFlacPass,
                                                fallback.AudioAllowTrueHDPass));

                    HBAudioEncoder autoPassthruEncoderOption = HandBrakeEncoderHelpers.GetAutoPassthruEncoder(sourceTrack.Codec, copyMask, fallbackEncoderInfo.Id, format);
                    AudioEncoder   autoPassthru = EnumHelper <AudioEncoder> .GetValue(autoPassthruEncoderOption.ShortName);

                    chosenEncoder = autoPassthru;
                }
            }

            encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper <AudioEncoder> .GetShortName(chosenEncoder));

            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;

            if (!string.IsNullOrEmpty(this.scannedTrack?.Name))
            {
                this.TrackName = this.scannedTrack.Name;
            }

            this.SetupLimits();
        }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AudioTrack"/> class.
        /// Copy Constructor
        /// </summary>
        /// <param name="track">
        /// The track.
        /// </param>
        /// <param name="setScannedTrack">
        /// The set Scanned Track.
        /// </param>
        public AudioTrack(AudioTrack track, bool setScannedTrack)
        {
            this.bitrate = track.Bitrate;
            this.drc = track.DRC;
            this.encoder = track.Encoder;
            this.gain = track.Gain;
            this.mixDown = track.MixDown;
            this.sampleRate = track.SampleRate;
            if (setScannedTrack)
            {
                this.scannedTrack = track.ScannedTrack ?? new Audio();
            }
            this.TrackName = track.TrackName;
            this.Quality = track.Quality;

            // Setup Backing Properties
            this.encoderRateType = track.EncoderRateType;
            this.SetupLimits();
        }