diff options
Diffstat (limited to 'win')
9 files changed, 285 insertions, 23 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs index bebfeca18..2ec14a1e2 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs @@ -257,10 +257,10 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories }
else
{
- video.Level = job.VideoLevel.ShortName;
+ video.Level = job.VideoLevel != null ? job.VideoLevel.ShortName : null;
video.Options = job.ExtraAdvancedArguments;
- video.Preset = job.VideoPreset.ShortName;
- video.Profile = job.VideoProfile.ShortName;
+ video.Preset = job.VideoPreset != null ? job.VideoPreset.ShortName : null;
+ video.Profile = job.VideoProfile != null ? job.VideoProfile.ShortName : null;
}
if (job.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) video.Quality = job.Quality;
diff --git a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs new file mode 100644 index 000000000..76be941bc --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBurnInBehaviourConverter.cs @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleBurnInBehaviourConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Subtitle Behaviour Converter
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Subtitles
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Model.Subtitles;
+
+ /// <summary>
+ /// Subtitle Behaviour Converter
+ /// </summary>
+ public class SubtitleBurnInBehaviourConverter : IValueConverter
+ {
+ /// <summary>
+ /// The convert.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && value.GetType() == typeof(BindingList<SubtitleBurnInBehaviourModes>))
+ {
+ return
+ new BindingList<string>(
+ EnumHelper<SubtitleBurnInBehaviourModes>.GetEnumDisplayValues(typeof(SubtitleBurnInBehaviourModes)).ToList());
+ }
+
+ if (value != null && value.GetType() == typeof(SubtitleBehaviourModes))
+ {
+ return EnumHelper<SubtitleBurnInBehaviourModes>.GetDisplay((SubtitleBurnInBehaviourModes)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// The convert back.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string name = value as string;
+ if (!string.IsNullOrEmpty(name))
+ {
+ return EnumHelper<SubtitleBurnInBehaviourModes>.GetValue(name);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index dd5ee90ed..f8e754663 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -139,6 +139,7 @@ <Compile Include="Controls\SplitButton\SplitMenuButton.cs" />
<Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
<Compile Include="Converters\Filters\DenoisePresetConverter.cs" />
+ <Compile Include="Converters\Subtitles\SubtitleBurnInBehaviourConverter.cs" />
<Compile Include="Converters\Subtitles\SubtitleBehaviourConverter.cs" />
<Compile Include="Converters\Video\VideoOptionsTooltipConverter.cs" />
<Compile Include="Converters\Video\ScalingConverter.cs" />
@@ -150,6 +151,7 @@ <Compile Include="Model\Audio\AudioBehaviours.cs" />
<Compile Include="Model\DriveInformation.cs" />
<Compile Include="Model\Picture\PresetPictureSettingsMode.cs" />
+ <Compile Include="Model\Subtitles\SubtitleBurnInBehaviourModes.cs" />
<Compile Include="Model\Subtitles\SubtitleBehaviourModes.cs" />
<Compile Include="Model\Subtitles\SubtitleBehaviours.cs" />
<Compile Include="Services\Interfaces\IQueueProcessor.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs index 8570f00e7..db5b7eb39 100644 --- a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs +++ b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs @@ -19,25 +19,11 @@ namespace HandBrakeWPF.Model.Subtitles /// </summary>
public class SubtitleBehaviours : PropertyChangedBase
{
- /// <summary>
- /// The selected behaviour.
- /// </summary>
private SubtitleBehaviourModes selectedBehaviour;
-
- /// <summary>
- /// The selected langauges.
- /// </summary>
private BindingList<string> selectedLangauges;
-
- /// <summary>
- /// The add foreign audio scan track.
- /// </summary>
private bool addForeignAudioScanTrack;
-
- /// <summary>
- /// The add closed captions.
- /// </summary>
private bool addClosedCaptions;
+ private SubtitleBurnInBehaviourModes selectedBurnInBehaviour;
/// <summary>
/// Initializes a new instance of the <see cref="SubtitleBehaviours"/> class.
@@ -45,6 +31,7 @@ namespace HandBrakeWPF.Model.Subtitles public SubtitleBehaviours()
{
this.SelectedBehaviour = SubtitleBehaviourModes.None;
+ this.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None;
this.SelectedLangauges = new BindingList<string>();
}
@@ -57,6 +44,7 @@ namespace HandBrakeWPF.Model.Subtitles public SubtitleBehaviours(SubtitleBehaviours behaviours)
{
this.SelectedBehaviour = behaviours.selectedBehaviour;
+ this.SelectedBurnInBehaviour = behaviours.selectedBurnInBehaviour;
this.SelectedLangauges = new BindingList<string>(behaviours.SelectedLangauges.ToList());
}
@@ -81,6 +69,26 @@ namespace HandBrakeWPF.Model.Subtitles }
/// <summary>
+ /// Gets or sets the selected burn in behaviour.
+ /// </summary>
+ public SubtitleBurnInBehaviourModes SelectedBurnInBehaviour
+ {
+ get
+ {
+ return this.selectedBurnInBehaviour;
+ }
+ set
+ {
+ if (value == this.selectedBurnInBehaviour)
+ {
+ return;
+ }
+ this.selectedBurnInBehaviour = value;
+ this.NotifyOfPropertyChange(() => this.SelectedBurnInBehaviour);
+ }
+ }
+
+ /// <summary>
/// Gets or sets the selected langages.
/// </summary>
public BindingList<string> SelectedLangauges
@@ -151,6 +159,7 @@ namespace HandBrakeWPF.Model.Subtitles SubtitleBehaviours cloned = new SubtitleBehaviours
{
SelectedBehaviour = this.selectedBehaviour,
+ SelectedBurnInBehaviour = this.selectedBurnInBehaviour,
SelectedLangauges = new BindingList<string>(),
AddClosedCaptions = this.addClosedCaptions,
AddForeignAudioScanTrack = this.addForeignAudioScanTrack,
diff --git a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs new file mode 100644 index 000000000..174b4a5e8 --- /dev/null +++ b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs @@ -0,0 +1,31 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleBurnInBehaviourModes.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The subtitle behaviours modes.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Model.Subtitles
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The subtitle behaviours modes.
+ /// </summary>
+ public enum SubtitleBurnInBehaviourModes
+ {
+ [Display(Name = "None")]
+ None = 0,
+
+ [Display(Name = "Foreign Audio Track")]
+ ForeignAudio,
+
+ [Display(Name = "First Track")]
+ FirstTrack,
+
+ [Display(Name = "Foreign Audio Preferred, else First")]
+ ForeignAudioPreferred,
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 5c4097933..3f26afe6e 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -901,6 +901,18 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to None - Only tracks where the container does not support the format will be burned in.
+ ///Foreign Audio Track - The Foreign Audio track will be burned in if available.
+ ///First Track - The first track will be burned in.
+ ///Foreign Audio Preferred, else First - If the foreign audio track exists, it will be burned in, otherwise the first track will be chosen..
+ /// </summary>
+ public static string Subtitles_BurnInBehaviourModes {
+ get {
+ return ResourceManager.GetString("Subtitles_BurnInBehaviourModes", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Updated.
/// </summary>
public static string Updated {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 2a3222d1d..2bc82bd71 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -556,4 +556,10 @@ Please use the 'Extra Options' box on the 'Video' tab to input any additional en <value>You cannot overwrite the source file you want to convert.
Please choose a different filename.</value>
</data>
+ <data name="Subtitles_BurnInBehaviourModes" xml:space="preserve">
+ <value>None - Only tracks where the container does not support the format will be burned in.
+Foreign Audio Track - The Foreign Audio track will be burned in if available.
+First Track - The first track will be burned in.
+Foreign Audio Preferred, else First - If the foreign audio track exists, it will be burned in, otherwise the first track will be chosen.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 425417cf1..33aa86be1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -193,6 +193,17 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets the subtitle burn in behaviour mode list.
+ /// </summary>
+ public BindingList<SubtitleBurnInBehaviourModes> SubtitleBurnInBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<SubtitleBurnInBehaviourModes>(EnumHelper<SubtitleBurnInBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
/// Gets or sets AvailableLanguages.
/// </summary>
public BindingList<string> AvailableLanguages
@@ -418,6 +429,62 @@ namespace HandBrakeWPF.ViewModels break;
}
+ // Burn In Behaviour
+ if (this.Task.SubtitleTracks.Count >= 1)
+ {
+ bool burnInSet = false;
+ switch (this.SubtitleBehaviours.SelectedBurnInBehaviour)
+ {
+ case SubtitleBurnInBehaviourModes.None:
+ // Do Nothing. Only tracks where the container requires it will be burned in.
+ break;
+ case SubtitleBurnInBehaviourModes.ForeignAudio:
+ foreach (var track in this.Task.SubtitleTracks)
+ {
+ // Set the Foreign Audio Track to burned-in
+ if (track.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch)
+ {
+ track.Burned = true;
+ this.SetBurnedToFalseForAllExcept(track);
+ break;
+ }
+ }
+ break;
+ case SubtitleBurnInBehaviourModes.FirstTrack:
+ foreach (var track in this.Task.SubtitleTracks)
+ {
+ // Set the first track.
+ if (!burnInSet && track.SourceTrack.SubtitleType != SubtitleType.ForeignAudioSearch)
+ {
+ burnInSet = true;
+ track.Burned = true;
+ this.SetBurnedToFalseForAllExcept(track);
+ }
+ }
+ break;
+ case SubtitleBurnInBehaviourModes.ForeignAudioPreferred:
+ foreach (var track in this.Task.SubtitleTracks)
+ {
+ // Set the first track.
+ if (!burnInSet)
+ {
+ burnInSet = true;
+ track.Burned = true;
+ this.SetBurnedToFalseForAllExcept(track);
+ }
+
+ // But if there is a foreign audio track, prefer this to the first.
+ if (track.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch)
+ {
+ track.Burned = true;
+ this.SetBurnedToFalseForAllExcept(track);
+ break;
+ }
+ }
+ break;
+ }
+ }
+
// Add all closed captions if enabled.
if (this.SubtitleBehaviours.AddClosedCaptions)
{
@@ -491,6 +558,14 @@ namespace HandBrakeWPF.ViewModels this.SubtitleBehaviours.SelectedLangauges.Clear();
}
+ /// <summary>
+ /// Reload the audio tracks based on the defaults.
+ /// </summary>
+ public void ReloadDefaults()
+ {
+ this.AutomaticSubtitleSelection();
+ }
+
#endregion
#region Implemented Interfaces
@@ -592,9 +667,17 @@ namespace HandBrakeWPF.ViewModels SourceTrack = source,
};
- if ((source.SubtitleType == SubtitleType.PGS || source.SubtitleType == SubtitleType.ForeignAudioSearch)
- && this.Task != null
- && this.Task.OutputFormat == OutputFormat.Mp4)
+
+ // Burn-in Behaviours
+ if (this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudio
+ || this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudioPreferred)
+ {
+ track.Burned = true;
+ this.SetBurnedToFalseForAllExcept(track);
+ }
+
+ // For MP4, PGS Subtitles must be burned in.
+ if (!track.Burned && (source.SubtitleType == SubtitleType.PGS) && this.Task != null && this.Task.OutputFormat == OutputFormat.Mp4)
{
if (track.CanBeBurned)
{
@@ -670,6 +753,7 @@ namespace HandBrakeWPF.ViewModels {
// Step 1, Set the behaviour mode
this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None;
+ this.SubtitleBehaviours.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None;
this.SubtitleBehaviours.AddClosedCaptions = false;
this.SubtitleBehaviours.AddForeignAudioScanTrack = false;
this.SubtitleBehaviours.SelectedLangauges.Clear();
@@ -689,6 +773,7 @@ namespace HandBrakeWPF.ViewModels if (preset != null && preset.SubtitleTrackBehaviours != null)
{
this.SubtitleBehaviours.SelectedBehaviour = preset.SubtitleTrackBehaviours.SelectedBehaviour;
+ this.SubtitleBehaviours.SelectedBurnInBehaviour = preset.SubtitleTrackBehaviours.SelectedBurnInBehaviour;
this.SubtitleBehaviours.AddClosedCaptions = preset.SubtitleTrackBehaviours.AddClosedCaptions;
this.SubtitleBehaviours.AddForeignAudioScanTrack = preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack;
diff --git a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml index de2418ed7..cccbaf790 100644 --- a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml +++ b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml @@ -11,6 +11,7 @@ xmlns:splitButton="clr-namespace:HandBrakeWPF.Controls.SplitButton"
xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
xmlns:subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles"
+ xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
d:DesignHeight="350"
d:DesignWidth="500"
mc:Ignorable="d"
@@ -18,6 +19,15 @@ <UserControl.Resources>
<Converters:BooleanToVisibilityConverter x:Key="booleanToVisConverter" />
<subtitles:SubtitleBehaviourConverter x:Key="subtitleBehaviourConverter" />
+ <subtitles:SubtitleBurnInBehaviourConverter x:Key="subtitleBurnInBehaviourConverter" />
+
+ <Style x:Key="LongToolTip" TargetType="TextBlock">
+ <Setter Property="Width" Value="400" />
+ <Setter Property="TextWrapping" Value="Wrap" />
+ <Setter Property="ToolTipService.ShowDuration" Value="20000" />
+ <Setter Property="Margin" Value="0,2,0,2" />
+ </Style>
+
</UserControl.Resources>
<Grid>
@@ -71,6 +81,13 @@ Margin="0,0,10,0"
cal:Message.Attach="[Event Click] = [Action ShowSubtitleDefaultsPanel]"
Content="{Binding SwitchDisplayTitle}" />
+
+ <Button MinWidth="65"
+ Margin="0,0,10,0"
+ cal:Message.Attach="[Event Click] = [Action ReloadDefaults]"
+ Content="Reload Defaults" />
+
+
</StackPanel>
@@ -284,6 +301,7 @@ <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -299,9 +317,17 @@ <ComboBox Name="autoSubtitleMode" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left"
ItemsSource="{Binding SubtitleBehaviourModeList, Converter={StaticResource subtitleBehaviourConverter}}"
SelectedItem="{Binding SubtitleBehaviours.SelectedBehaviour, Converter={StaticResource subtitleBehaviourConverter}}" Width="210" Margin="0,0,5,0" />
- <CheckBox Content="Add Closed Captions when available" Grid.Column="3" Grid.Row="1" Margin="0,5,0,0"
+ <TextBlock Text="Burn-In Behaviour:" Grid.Column="2" Grid.Row="1" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
+ <ComboBox Name="burninBehaviour" Grid.Column="3" Grid.Row="1" HorizontalAlignment="Left"
+ ItemsSource="{Binding SubtitleBurnInBehaviourModeList, Converter={StaticResource subtitleBurnInBehaviourConverter}}"
+ SelectedItem="{Binding SubtitleBehaviours.SelectedBurnInBehaviour, Converter={StaticResource subtitleBurnInBehaviourConverter}}" Width="210" Margin="0,5,5,0">
+ <ComboBox.ToolTip>
+ <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static Properties:Resources.Subtitles_BurnInBehaviourModes}" />
+ </ComboBox.ToolTip>
+ </ComboBox>
+ <CheckBox Content="Add Closed Captions when available" Grid.Column="3" Grid.Row="2" Margin="0,5,0,0"
HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddClosedCaptions}"/>
- <CheckBox Content="Add 'Foreign Audio Scan'" Grid.Column="3" Grid.Row="2" Margin="0,5,0,0"
+ <CheckBox Content="Add 'Foreign Audio Scan'" Grid.Column="3" Grid.Row="3" Margin="0,5,0,0"
HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddForeignAudioScanTrack}"/>
</Grid>
|