diff options
5 files changed, 27 insertions, 11 deletions
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs index 3a3847b85..0977334f6 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs @@ -9,8 +9,6 @@ namespace HandBrakeWPF.Model.Audio
{
- using System.ComponentModel.DataAnnotations;
-
using HandBrake.ApplicationServices.Attributes;
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs index 30aa9906d..6647b7fdf 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs @@ -348,6 +348,12 @@ namespace HandBrakeWPF.Services.Encode.Factories HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(item.Encoder)); Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); + if (item.IsPassthru && (item.ScannedTrack.Codec & encoder.Id) == 0) + { + // We have an unsupported passthru. Rather than let libhb drop the track, switch it to the fallback. + encoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback)); + } + HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(item.MixDown); HBRate sampleRate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(s => s.Name == item.SampleRate.ToString(CultureInfo.InvariantCulture)); diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs index 2dd42c190..2d659bd39 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioEncoder.cs @@ -9,8 +9,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models { - using System.ComponentModel.DataAnnotations; - using HandBrake.ApplicationServices.Attributes; /// <summary> diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs index bf5ea27d4..6dede959d 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs @@ -14,6 +14,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models using System.ComponentModel; using System.Globalization; using System.Linq; + using System.Security; using HandBrake.ApplicationServices.Interop; using HandBrake.ApplicationServices.Interop.Model; @@ -102,14 +103,27 @@ namespace HandBrakeWPF.Services.Encode.Model.Models /// <param name="track"> /// The Behavior track /// </param> - public AudioTrack(AudioBehaviourTrack track) - { + /// <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 = track.Encoder; + this.encoder = chosenEncoder; this.gain = track.Gain; this.mixDown = track.MixDown != null ? track.MixDown.ShortName : "dpl2"; this.sampleRate = track.SampleRate; - this.scannedTrack = new Audio(); this.encoderRateType = track.EncoderRateType; this.quality = track.Quality; this.bitrate = track.Bitrate; diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index 1381fcca0..c90c9add3 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -338,12 +338,12 @@ namespace HandBrakeWPF.ViewModels break;
case AudioTrackDefaultsMode.FirstTrack:
AudioBehaviourTrack template = this.AudioBehaviours.BehaviourTracks.FirstOrDefault();
- this.Task.AudioTracks.Add(template != null ? new AudioTrack(template) { ScannedTrack = track } : new AudioTrack { ScannedTrack = track });
+ this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
break;
case AudioTrackDefaultsMode.AllTracks:
foreach (AudioBehaviourTrack tmpl in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl) { ScannedTrack = track } : new AudioTrack { ScannedTrack = track });
+ this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
}
break;
@@ -395,7 +395,7 @@ namespace HandBrakeWPF.ViewModels // Step 3, Setup the tracks from the preset
foreach (AudioBehaviourTrack track in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = this.GetPreferredAudioTrack() });
+ this.Task.AudioTracks.Add(new AudioTrack(track, this.GetPreferredAudioTrack(), this.Task.AllowedPassthruOptions.AudioEncoderFallback));
}
// Step 4, Handle the default selection behaviour.
|