summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs8
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs10
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs21
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs16
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs74
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs19
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs9
7 files changed, 142 insertions, 15 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index 90a3d249f..9af13bc71 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -209,6 +209,14 @@ namespace HandBrakeWPF.ViewModels
}
}
+ if (this.Task.OutputFormat == OutputFormat.WebM)
+ {
+ foreach (AudioTrack track in this.Task.AudioTracks.Where(track => track.Encoder != AudioEncoder.Vorbis && track.Encoder != AudioEncoder.Opus))
+ {
+ track.Encoder = AudioEncoder.Vorbis;
+ }
+ }
+
this.AudioDefaultsViewModel.RefreshTask();
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
index c5f0f5e3c..4889332ee 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
@@ -28,5 +28,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces
/// String array of files.
/// </param>
void Import(string[] subtitleFiles);
+
+ /// <summary>
+ /// Trigger a Notify Property Changed on the Task to force various UI elements to update.
+ /// </summary>
+ void RefreshTask();
+
+ /// <summary>
+ /// Checks the configuration of the subtitles and warns the user about any potential issues.
+ /// </summary>
+ bool ValidateSubtitles();
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index de7070d3d..2f0baa730 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -556,7 +556,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Gets RangeMode.
/// </summary>
- public IEnumerable<OutputFormat> OutputFormats => new List<OutputFormat> { OutputFormat.Mp4, OutputFormat.Mkv };
+ public IEnumerable<OutputFormat> OutputFormats => new List<OutputFormat> { OutputFormat.Mp4, OutputFormat.Mkv, OutputFormat.WebM };
/// <summary>
/// Gets or sets Destination.
@@ -608,6 +608,9 @@ namespace HandBrakeWPF.ViewModels
case ".m4v":
this.SummaryViewModel.SetContainer(OutputFormat.Mp4);
break;
+ case ".webm":
+ this.SummaryViewModel.SetContainer(OutputFormat.WebM);
+ break;
}
}
else
@@ -1154,6 +1157,7 @@ namespace HandBrakeWPF.ViewModels
this.VideoViewModel.RefreshTask();
this.AudioViewModel.RefreshTask();
+ this.SubtitleViewModel.RefreshTask();
}
public void Shutdown()
@@ -1377,6 +1381,12 @@ namespace HandBrakeWPF.ViewModels
return new AddQueueError(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
+ // defer to subtitle's validation messages
+ if (!this.SubtitleViewModel.ValidateSubtitles())
+ {
+ return false;
+ }
+
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create(), this.ScannedSource.ScanPath, this.SelectedPreset);
if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination))
@@ -1731,7 +1741,7 @@ namespace HandBrakeWPF.ViewModels
{
SaveFileDialog saveFileDialog = new SaveFileDialog
{
- Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",
+ Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv|webm|*.webm",
CheckPathExists = true,
AddExtension = true,
DefaultExt = ".mp4",
@@ -1743,7 +1753,9 @@ namespace HandBrakeWPF.ViewModels
saveFileDialog.FilterIndex = !string.IsNullOrEmpty(this.CurrentTask.Destination)
&& !string.IsNullOrEmpty(extension)
? (extension == ".mp4" || extension == ".m4v" ? 1 : 2)
- : (this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 2 : 0);
+ : (this.CurrentTask.OutputFormat == OutputFormat.Mkv
+ ? 2
+ : (this.CurrentTask.OutputFormat == OutputFormat.WebM ? 3 : 0));
string mruDir = this.GetMru(Constants.FileSaveMru);
if (!string.IsNullOrEmpty(mruDir))
@@ -1781,6 +1793,9 @@ namespace HandBrakeWPF.ViewModels
case ".m4v":
this.SummaryViewModel.SetContainer(OutputFormat.Mp4);
break;
+ case ".webm":
+ this.SummaryViewModel.SetContainer(OutputFormat.WebM);
+ break;
}
this.NotifyOfPropertyChange(() => this.CurrentTask);
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index d8ad6e9b9..5a9c38383 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -570,7 +570,21 @@ namespace HandBrakeWPF.ViewModels
// Filename handling.
if (string.IsNullOrEmpty(encodeTask.Destination))
{
- string filename = Path.ChangeExtension(Path.GetTempFileName(), encodeTask.OutputFormat == OutputFormat.Mkv ? "m4v" : "mkv");
+ string formatExtension;
+ switch (encodeTask.OutputFormat)
+ {
+ case OutputFormat.WebM:
+ formatExtension = "webm";
+ break;
+ case OutputFormat.Mp4:
+ formatExtension = "m4v";
+ break;
+ case OutputFormat.Mkv:
+ default:
+ formatExtension = "mkv";
+ break;
+ }
+ string filename = Path.ChangeExtension(Path.GetTempFileName(), formatExtension);
encodeTask.Destination = filename;
this.CurrentlyPlaying = filename;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index e164f1192..432e15f51 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -14,6 +14,7 @@ namespace HandBrakeWPF.ViewModels
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
+ using System.Windows;
using Caliburn.Micro;
@@ -22,6 +23,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Properties;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -38,6 +40,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public class SubtitlesViewModel : ViewModelBase, ISubtitlesViewModel
{
+ private readonly IErrorService errorService;
private readonly IWindowManager windowManager;
#region Constants and Fields
@@ -52,11 +55,15 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class.
/// </summary>
+ /// <param name="errorService">
+ /// The Error Service
+ /// </param>
/// <param name="windowManager">
/// The window Manager.
/// </param>
- public SubtitlesViewModel(IWindowManager windowManager)
+ public SubtitlesViewModel(IErrorService errorService, IWindowManager windowManager)
{
+ this.errorService = errorService;
this.windowManager = windowManager;
this.SubtitleDefaultsViewModel = new SubtitlesDefaultsViewModel();
this.Task = new EncodeTask();
@@ -144,6 +151,14 @@ namespace HandBrakeWPF.ViewModels
}
}
+ public bool IsBurnableOnly
+ {
+ get
+ {
+ return this.Task.OutputFormat == OutputFormat.WebM;
+ }
+ }
+
#endregion
#region Public Methods
@@ -453,6 +468,26 @@ namespace HandBrakeWPF.ViewModels
this.AutomaticSubtitleSelection();
}
+ /// <summary>
+ /// Trigger a Notify Property Changed on the Task to force various UI elements to update.
+ /// </summary>
+ public void RefreshTask()
+ {
+ this.NotifyOfPropertyChange(() => this.Task);
+ this.NotifyOfPropertyChange(() => this.IsBurnableOnly);
+
+ if (this.IsBurnableOnly)
+ {
+ foreach (var subtitleTrack in this.Task.SubtitleTracks)
+ {
+ if (subtitleTrack.Default)
+ {
+ subtitleTrack.Default = false;
+ }
+ }
+ }
+ }
+
#endregion
#region Implemented Interfaces
@@ -553,6 +588,43 @@ namespace HandBrakeWPF.ViewModels
this.AutomaticSubtitleSelection();
}
+ /// <summary>
+ /// Checks the configuration of the subtitles and warns the user about any potential issues.
+ /// </summary>
+ public bool ValidateSubtitles()
+ {
+ var nonBurnedSubtitles = this.Task.SubtitleTracks.Where(subtitleTrack => !subtitleTrack.Burned).ToList();
+
+ if (nonBurnedSubtitles.Count > 0 && this.IsBurnableOnly)
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(
+ Resources.Subtitles_WebmSubtitleIncompatibilityError,
+ Resources.Subtitles_WebmSubtitleIncompatibilityHeader,
+ MessageBoxButton.OKCancel,
+ MessageBoxImage.Warning);
+ if (result == MessageBoxResult.OK)
+ {
+ foreach (var subtitleTrack in nonBurnedSubtitles)
+ {
+ if (!subtitleTrack.Burned)
+ {
+ this.Remove(subtitleTrack);
+ }
+ }
+ }
+ else if (result == MessageBoxResult.Cancel)
+ {
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
#endregion
#region Methods
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
index 0da1fc70b..b5f711e5a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
@@ -123,7 +123,7 @@ namespace HandBrakeWPF.ViewModels
{
return new List<OutputFormat>
{
- OutputFormat.Mp4, OutputFormat.Mkv
+ OutputFormat.Mp4, OutputFormat.Mkv, OutputFormat.WebM
};
}
}
@@ -211,8 +211,9 @@ namespace HandBrakeWPF.ViewModels
this.Task.OutputFormat = value;
this.NotifyOfPropertyChange(() => this.SelectedOutputFormat);
this.NotifyOfPropertyChange(() => this.Task.OutputFormat);
- this.NotifyOfPropertyChange(() => this.IsMkv);
+ this.NotifyOfPropertyChange(() => this.IsMkvOrWebm);
this.SetExtension(string.Format(".{0}", this.Task.OutputFormat.ToString().ToLower()));
+ this.UpdateDisplayedInfo(); // output format may coreced to another due to container incompatibility
this.OnOutputFormatChanged(new OutputFormatChangedEventArgs(null));
this.OnTabStatusChanged(null);
@@ -221,13 +222,13 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets or sets a value indicating whether IsMkv.
+ /// Gets or sets a value indicating whether IsMkvOrWebm.
/// </summary>
- public bool IsMkv
+ public bool IsMkvOrWebm
{
get
{
- return this.SelectedOutputFormat == OutputFormat.Mkv;
+ return this.SelectedOutputFormat == OutputFormat.Mkv || this.SelectedOutputFormat == OutputFormat.WebM;
}
}
@@ -316,8 +317,8 @@ namespace HandBrakeWPF.ViewModels
this.UpdateDisplayedInfo();
this.NotifyOfPropertyChange(() => this.SelectedOutputFormat);
- this.NotifyOfPropertyChange(() => this.IsMkv);
-
+ this.NotifyOfPropertyChange(() => this.IsMkvOrWebm);
+
this.NotifyOfPropertyChange(() => this.OptimizeMP4);
this.NotifyOfPropertyChange(() => this.IPod5GSupport);
this.NotifyOfPropertyChange(() => this.AlignAVStart);
@@ -454,14 +455,14 @@ namespace HandBrakeWPF.ViewModels
}
// Now disable controls that are not required. The Following are for MP4 only!
- if (newExtension == ".mkv")
+ if (newExtension == ".mkv" || newExtension == ".webm")
{
this.OptimizeMP4 = false;
this.IPod5GSupport = false;
this.AlignAVStart = false;
}
- this.NotifyOfPropertyChange(() => this.IsMkv);
+ this.NotifyOfPropertyChange(() => this.IsMkvOrWebm);
// Update The browse file extension display
if (Path.HasExtension(newExtension))
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 72b74ffa1..3280b9424 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -1115,10 +1115,17 @@ namespace HandBrakeWPF.ViewModels
{
this.NotifyOfPropertyChange(() => this.Task);
- if ((Task.OutputFormat == OutputFormat.Mp4) && this.SelectedVideoEncoder == VideoEncoder.Theora)
+ VideoEncoder[] allowableWebmEncoders = { VideoEncoder.VP8, VideoEncoder.VP9 };
+
+ if ((Task.OutputFormat == OutputFormat.Mp4) && (this.SelectedVideoEncoder == VideoEncoder.Theora || allowableWebmEncoders.Contains(this.SelectedVideoEncoder)))
{
this.SelectedVideoEncoder = VideoEncoder.X264;
}
+
+ if ((Task.OutputFormat == OutputFormat.WebM) && !allowableWebmEncoders.Contains(this.SelectedVideoEncoder))
+ {
+ this.SelectedVideoEncoder = VideoEncoder.VP8;
+ }
}
/// <summary>