Пример #1
0
        /// <summary>
        /// Update all the UI controls based on the encode task passed in.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        public void UpdateTask(EncodeTask task)
        {
            this.Task = task;

            this.NotifyOfPropertyChange(() => this.IncludeChapterMarkers);
            this.NotifyOfPropertyChange(() => this.Chapters);
        }
Пример #2
0
        /// <summary>
        /// Setup this tab for the specified preset.
        /// </summary>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetPreset(Preset preset, EncodeTask task)
        {
            // Note, We don't support Subtitles in presets yet.
            this.Task = task;
            this.NotifyOfPropertyChange(() => this.Task);

            this.SubtitleBehaviours = new SubtitleBehaviours(preset.SubtitleTrackBehaviours);

            this.SubtitleDefaultsViewModel.SetupPreset(preset);
            this.AutomaticSubtitleSelection();
        }
Пример #3
0
        public void SetPreset(Preset preset, EncodeTask task)
        {
            this.CurrentTask = task;

            this.SharpenFilter.SetPreset(preset, task);
            this.DenoiseFilter.SetPreset(preset, task);
            this.DetelecineFilter.SetPreset(preset, task);
            this.DeinterlaceFilter.SetPreset(preset, task);
            this.DeblockFilter.SetPreset(preset, task);
            this.ColourSpaceFilter.SetPreset(preset, task);
            this.ChromaSmoothFilter.SetPreset(preset, task);
        }
Пример #4
0
 public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
 {
     this.CurrentTask = task;
     this.SharpenFilter.SetSource(source, title, preset, task);
     this.DenoiseFilter.SetSource(source, title, preset, task);
     this.DetelecineFilter.SetSource(source, title, preset, task);
     this.DeinterlaceFilter.SetSource(source, title, preset, task);
     this.DeblockFilter.SetSource(source, title, preset, task);
     this.GrayscaleFilter.SetSource(source, title, preset, task);
     this.ColourSpaceFilter.SetSource(source, title, preset, task);
     this.ChromaSmoothFilter.SetSource(source, title, preset, task);
 }
Пример #5
0
        /// <summary>
        /// Setup this window for a new source
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
        {
            this.Task = task;

            if (preset != null)
            {
                this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
            }

            this.sourceChaptersList = title.Chapters;
            this.SetSourceChapters(title.Chapters);
        }
Пример #6
0
        public void UpdateTask(EncodeTask task)
        {
            this.CurrentTask = task;

            this.SharpenFilter.UpdateTask(task);
            this.DenoiseFilter.UpdateTask(task);
            this.DetelecineFilter.UpdateTask(task);
            this.DeinterlaceFilter.UpdateTask(task);
            this.DeblockFilter.UpdateTask(task);
            this.GrayscaleFilter.UpdateTask(task);
            this.ColourSpaceFilter.UpdateTask(task);
            this.ChromaSmoothFilter.UpdateTask(task);
        }
Пример #7
0
        /// <summary>
        /// Setup this window for a new source
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
        {
            this.SourceTracks.Clear();
            this.SourceTracks.Add(foreignAudioSearchTrack);
            foreach (Subtitle subtitle in title.Subtitles)
            {
                this.SourceTracks.Add(subtitle);
            }

            this.Task = task;
            this.NotifyOfPropertyChange(() => this.Task);

            this.AutomaticSubtitleSelection();
        }
Пример #8
0
        /// <summary>
        /// Setup this tab for the specified preset.
        /// </summary>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetPreset(Preset preset, EncodeTask task)
        {
            this.Task          = task;
            this.currentPreset = preset;

            // Audio Behaviours
            this.AudioDefaultsViewModel.Setup(preset, task);

            if (preset != null && preset.Task != null)
            {
                this.SetupTracks();
            }

            this.NotifyOfPropertyChange(() => this.Task);
        }
Пример #9
0
        /// <summary>
        /// Setup this tab for the specified preset.
        /// </summary>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetPreset(Preset preset, EncodeTask task)
        {
            this.Task = task;

            // Audio Behaviours
            this.AudioDefaultsViewModel.Setup(preset.AudioTrackBehaviours, preset.Task.OutputFormat);
            this.AudioBehaviours = new AudioBehaviours(preset.AudioTrackBehaviours);

            if (preset.Task != null)
            {
                this.SetupTracks();
            }

            this.NotifyOfPropertyChange(() => this.Task);
        }
Пример #10
0
        /// <summary>
        /// Function which generates the filename and path automatically based on
        /// the Source Name, DVD title and DVD Chapters
        /// </summary>
        public static string AutoName(EncodeTask task, string titleName, string sourceDisplayName, Preset presetName)
        {
            IUserSettingService userSettingService = IoC.Get <IUserSettingService>();

            if (task.Destination == null)
            {
                task.Destination = string.Empty;
            }

            string sourceOrLabelName = !string.IsNullOrEmpty(titleName) ? titleName : sourceDisplayName;

            if (task.Title != 0)
            {
                // Get the Source Name and remove any invalid characters and clean it per users options.
                string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));
                sourceName = CleanupSourceName(sourceName, userSettingService);

                // Get the Selected Title Number
                string dvdTitle = task.Title.ToString();

                // Get the Chapter Start and Chapter End Numbers
                string chapterStart       = task.StartPoint.ToString();
                string chapterFinish      = task.EndPoint.ToString();
                string combinedChapterTag = chapterStart;
                if (chapterFinish != chapterStart && chapterFinish != string.Empty)
                {
                    combinedChapterTag = chapterStart + "-" + chapterFinish;
                }

                // Creation Date / Time
                var    creationDateTime = ObtainCreateDateObject(task);
                string createDate       = creationDateTime.Date.ToShortDateString().Replace('/', '-');
                string createTime       = creationDateTime.ToString("HH-mm");

                /*
                 * Generate the full path and filename
                 */
                string destinationFilename = GenerateDestinationFileName(task, userSettingService, sourceName, dvdTitle, combinedChapterTag, createDate, createTime);
                string autoNamePath        = GetAutonamePath(userSettingService, task, sourceName);
                string finalPath           = Path.Combine(autoNamePath, destinationFilename);

                autoNamePath = CheckAndHandleFilenameCollisions(finalPath, destinationFilename, task, userSettingService);
                return(autoNamePath);
            }

            return(string.Empty);
        }
        /// <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 && (task.VideoEncoder == VideoEncoder.X264 || task.VideoEncoder == VideoEncoder.X264_10 || task.VideoEncoder == VideoEncoder.X265 || task.VideoEncoder == VideoEncoder.X265_10 || task.VideoEncoder == VideoEncoder.X265_12))
            {
                VideoTune tune = task.VideoTunes.FirstOrDefault();

                return(string.Format("Preset: {0}{5}Tune: {1}{5}Profile: {2}{5}Level: {3}{5}Extra Arguments: {4}{5}",
                                     task.VideoPreset != null ? task.VideoPreset.ShortName : VideoPreset.None.DisplayName,
                                     tune != null ? tune.ShortName : VideoTune.None.DisplayName,
                                     task.VideoProfile != null ? task.VideoProfile.ShortName : VideoProfile.Auto.DisplayName,
                                     task.VideoLevel != null ? task.VideoLevel.ShortName : VideoLevel.Auto.DisplayName,
                                     string.IsNullOrEmpty(task.ExtraAdvancedArguments) ? "None" : task.ExtraAdvancedArguments,
                                     Environment.NewLine));
            }

            return(string.Empty);
        }
Пример #12
0
        /// <summary>
        /// Set the Source Title
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
        {
            this.SourceTracks = title.AudioTracks;

            // Only reset the audio tracks if we have none, or if the task is null.
            if (this.Task == null)
            {
                this.SetPreset(preset, task);
            }

            // If there are no source tracks, clear the list, otherwise try to Auto-Select the correct tracks
            if (this.SourceTracks == null || !this.SourceTracks.Any())
            {
                this.Task.AudioTracks.Clear();
            }
            else
            {
                this.SetupTracks();
            }

            // Force UI Updates
            this.NotifyOfPropertyChange(() => this.Task);
        }
Пример #13
0
        private static DateTime ObtainCreateDateObject(EncodeTask task)
        {
            var rd = task.MetaData.ReleaseDate;

            if (DateTime.TryParse(rd, out var d))
            {
                return(d);
            }

            try
            {
                return(File.GetCreationTime(task.Source));
            }
            catch (Exception e)
            {
                if (e is UnauthorizedAccessException || e is PathTooLongException || e is NotSupportedException)
                {
                    // Suspect the most likely concerns trying to grab the creation date in which we would want to swallow exception.
                    return(default(DateTime));
                }

                throw;
            }
        }
Пример #14
0
 /// <summary>
 /// Update all the UI controls based on the encode task passed in.
 /// </summary>
 /// <param name="task">
 /// The task.
 /// </param>
 public void UpdateTask(EncodeTask task)
 {
     this.Task = task;
     this.NotifyOfPropertyChange(() => this.Task.SubtitleTracks);
     this.NotifyOfPropertyChange(() => this.Task);
 }
Пример #15
0
        /// <summary>
        /// Gets a list of Video encoders OR returns the string name of an encoder depending on the input.
        /// </summary>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// IEnumberable VideoEncoder or String encoder name.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Count() >= 2)
            {
                IUserSettingService userSettingService = values[2] as IUserSettingService;
                bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false;
                if (userSettingService != null)
                {
                    isQsvEnabled   = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding);
                    isVceEnabled   = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder);
                    isNvencEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder);
                }

                List <VideoEncoder> encoders = EnumHelper <VideoEncoder> .GetEnumList().ToList();

                EncodeTask task = values[1] as EncodeTask;

                if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X264_10)))
                {
                    encoders.Remove(VideoEncoder.X264_10);
                }

                if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X265_10)))
                {
                    encoders.Remove(VideoEncoder.X265_10);
                }

                if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X265_12)))
                {
                    encoders.Remove(VideoEncoder.X265_12);
                }

                if (task != null && task.OutputFormat == OutputFormat.Mp4)
                {
                    encoders.Remove(VideoEncoder.Theora);
                    encoders.Remove(VideoEncoder.VP8);
                    encoders.Remove(VideoEncoder.VP9);
                }
                else if (task != null && task.OutputFormat == OutputFormat.WebM)
                {
                    encoders.RemoveAll(ve => !(ve.Equals(VideoEncoder.VP9) || ve.Equals(VideoEncoder.VP8)));
                }

                if (!isQsvEnabled || !HandBrakeHardwareEncoderHelper.IsQsvAvailableH264)
                {
                    encoders.Remove(VideoEncoder.QuickSync);
                }

                if (!isQsvEnabled || !HandBrakeHardwareEncoderHelper.IsQsvAvailableH265)
                {
                    encoders.Remove(VideoEncoder.QuickSyncH265);
                    encoders.Remove(VideoEncoder.QuickSyncH26510b);
                }
                else if (!HandBrakeHardwareEncoderHelper.IsQsvAvailableH26510bit)
                {
                    encoders.Remove(VideoEncoder.QuickSyncH26510b);
                }

                if (!isVceEnabled || !HandBrakeHardwareEncoderHelper.IsVceH264Available)
                {
                    encoders.Remove(VideoEncoder.VceH264);
                }

                if (!isVceEnabled || !HandBrakeHardwareEncoderHelper.IsVceH265Available)
                {
                    encoders.Remove(VideoEncoder.VceH265);
                }

                if (!isNvencEnabled || !HandBrakeHardwareEncoderHelper.IsNVEncH264Available)
                {
                    encoders.Remove(VideoEncoder.NvencH264);
                }

                if (!isNvencEnabled || !HandBrakeHardwareEncoderHelper.IsNVEncH265Available)
                {
                    encoders.Remove(VideoEncoder.NvencH265);
                }

                return(EnumHelper <VideoEncoder> .GetEnumDisplayValuesSubset(encoders));
            }

            if (values[0].GetType() == typeof(VideoEncoder))
            {
                return(EnumHelper <VideoEncoder> .GetDisplay((VideoEncoder)values[0]));
            }

            return(null);
        }
Пример #16
0
        private static string CheckAndHandleFilenameCollisions(string autoNamePath, string destinationFilename, EncodeTask task, IUserSettingService userSettingService)
        {
            AutonameFileCollisionBehaviour behaviour = (AutonameFileCollisionBehaviour)userSettingService.GetUserSetting <int>(UserSettingConstants.AutonameFileCollisionBehaviour);
            string prefix = string.Empty, postfix = string.Empty;

            switch (behaviour)
            {
            case AutonameFileCollisionBehaviour.Postfix:
                postfix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString);
                break;

            case AutonameFileCollisionBehaviour.Prefix:
                prefix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString);
                break;
            }

            string extension = Path.GetExtension(destinationFilename);
            string filenameWithoutExt = Path.GetFileNameWithoutExtension(destinationFilename);

            if (behaviour != AutonameFileCollisionBehaviour.AppendNumber)
            {
                autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + extension);

                int counter = 0;
                while (File.Exists(autoNamePath))
                {
                    counter = counter + 1;
                    string appendedNumber = string.Format("({0})", counter);
                    autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + appendedNumber + extension);
                }
            }
            else
            {
                int counter = 0;
                while (File.Exists(autoNamePath))
                {
                    counter = counter + 1;
                    string appendedNumber = string.Format("({0})", counter);
                    autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), filenameWithoutExt + appendedNumber + extension);
                }
            }

            return(autoNamePath);
        }
Пример #17
0
        private static string GetAutonamePath(IUserSettingService userSettingService, EncodeTask task, string sourceName)
        {
            string autoNamePath = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim().Replace("/", "\\");

            // If enabled, use the current Destination path.
            if (!userSettingService.GetUserSetting <bool>(UserSettingConstants.AlwaysUseDefaultPath) && !string.IsNullOrEmpty(task.Destination))
            {
                string path = Path.GetDirectoryName(task.Destination);
                if (!string.IsNullOrEmpty(path))
                {
                    return(path);
                }
            }

            // Handle {source_path}
            if (autoNamePath.StartsWith(Constants.SourcePath) && !string.IsNullOrEmpty(task.Source))
            {
                string savedPath = autoNamePath.Replace(Constants.SourcePath + "\\", string.Empty).Replace(Constants.SourcePath, string.Empty);
                string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source);
                autoNamePath = Path.Combine(directory, savedPath);
            }

            // Handle {source}
            if (autoNamePath.Contains(Constants.Source) && !string.IsNullOrEmpty(task.Source))
            {
                sourceName   = Path.GetInvalidPathChars().Aggregate(sourceName, (current, character) => current.Replace(character.ToString(), string.Empty));
                autoNamePath = autoNamePath.Replace(Constants.Source, sourceName);
            }

            // Handle {source_folder_name}
            if (autoNamePath.Contains(Constants.SourceFolderName) && !string.IsNullOrEmpty(task.Source))
            {
                // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source.
                string path = Path.GetDirectoryName(task.Source);
                if (!string.IsNullOrEmpty(path))
                {
                    string[] filesArray   = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                    string   sourceFolder = filesArray[filesArray.Length - 1];

                    autoNamePath = autoNamePath.Replace(Constants.SourceFolderName, sourceFolder);
                }
            }

            // Fallback to the users "Videos" folder.
            if (string.IsNullOrEmpty(autoNamePath) || autoNamePath == Resources.OptionsView_SetDefaultLocationOutputFIle)
            {
                autoNamePath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
            }

            return(autoNamePath);
        }
Пример #18
0
        private static string GenerateDestinationFileName(EncodeTask task, IUserSettingService userSettingService, string sourceName, string dvdTitle, string combinedChapterTag, string createDate, string createTime)
        {
            string destinationFilename;

            if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat) != string.Empty)
            {
                destinationFilename = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat);
                destinationFilename =
                    destinationFilename
                    .Replace(Constants.Source, sourceName)
                    .Replace(Constants.Title, dvdTitle)
                    .Replace(Constants.Chapters, combinedChapterTag)
                    .Replace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-'))
                    .Replace(Constants.Time, DateTime.Now.ToString("HH-mm"))
                    .Replace(Constants.CreationDate, createDate)
                    .Replace(Constants.CreationTime, createTime);

                if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
                {
                    destinationFilename = destinationFilename.Replace(Constants.Quality, task.Quality.ToString());
                    destinationFilename = destinationFilename.Replace(Constants.Bitrate, string.Empty);
                }
                else
                {
                    destinationFilename = destinationFilename.Replace(
                        Constants.Bitrate,
                        task.VideoBitrate.ToString());
                    destinationFilename = destinationFilename.Replace(Constants.Quality, string.Empty);
                }
            }
            else
            {
                destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
            }

            /*
             * File Extension
             */
            if (task.OutputFormat == OutputFormat.Mp4)
            {
                switch ((Mp4Behaviour)userSettingService.GetUserSetting <int>(UserSettingConstants.UseM4v))
                {
                case Mp4Behaviour.Auto:     // Automatic
                    destinationFilename += task.IncludeChapterMarkers || MP4Helper.RequiresM4v(task) ? ".m4v" : ".mp4";
                    break;

                case Mp4Behaviour.MP4:     // Always MP4
                    destinationFilename += ".mp4";
                    break;

                case Mp4Behaviour.M4V:     // Always M4V
                    destinationFilename += ".m4v";
                    break;
                }
            }
            else if (task.OutputFormat == OutputFormat.Mkv)
            {
                destinationFilename += ".mkv";
            }
            else if (task.OutputFormat == OutputFormat.WebM)
            {
                destinationFilename += ".webm";
            }

            return(destinationFilename);
        }
Пример #19
0
        /// <summary>
        /// Gets a list of audio encoders OR returns the string name of an encoder depending on the input.
        /// </summary>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// IEnumberable AudioEncoder or String encoder name.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            // TODO -> Be smarter and only show the available Passthru options.
            if (values.Count() >= 2)
            {
                List <AudioEncoder> encoders = EnumHelper <AudioEncoder> .GetEnumList().ToList();

                EncodeTask task = values[1] as EncodeTask;

                encoders.Remove(AudioEncoder.None); // Assume we never want to show this.

                if (!HandBrakeEncoderHelpers.AudioEncoders.Any(a => a.ShortName.Contains("fdk")))
                {
                    encoders.Remove(AudioEncoder.fdkaac);
                    encoders.Remove(AudioEncoder.fdkheaac);
                }

                if (task != null && task.OutputFormat == OutputFormat.Mp4)
                {
                    encoders.Remove(AudioEncoder.Vorbis);
                    encoders.Remove(AudioEncoder.ffflac);
                    encoders.Remove(AudioEncoder.ffflac24);
                    encoders.Remove(AudioEncoder.FlacPassthru);
                    encoders.Remove(AudioEncoder.Opus);

                    encoders.Remove(AudioEncoder.TrueHDPassthrough);
                }
                else if (task != null && task.OutputFormat == OutputFormat.WebM)
                {
                    encoders.RemoveAll(ae => !(ae.Equals(AudioEncoder.Vorbis) || ae.Equals(AudioEncoder.Opus)));
                }

                // Hide the Passthru options and show the "None" option
                if (parameter != null && parameter.ToString() == "True")
                {
                    encoders.Remove(AudioEncoder.DtsHDPassthrough);
                    encoders.Remove(AudioEncoder.DtsPassthrough);
                    encoders.Remove(AudioEncoder.EAc3Passthrough);
                    encoders.Remove(AudioEncoder.AacPassthru);
                    encoders.Remove(AudioEncoder.Ac3Passthrough);
                    encoders.Remove(AudioEncoder.Mp3Passthru);
                    encoders.Remove(AudioEncoder.Mp2Passthru);
                    encoders.Remove(AudioEncoder.Passthrough);
                    encoders.Remove(AudioEncoder.TrueHDPassthrough);
                    encoders.Remove(AudioEncoder.FlacPassthru);

                    encoders.Add(AudioEncoder.None);
                }

                if (values.Length == 3)
                {
                    encoders.Remove(AudioEncoder.Passthrough); // Auto passthru doesn't make sense on the main window. instead only show supported passthrus.

                    Audio sourceTrack = values[2] as Audio;
                    RemoveIfNotSupported(AudioEncoder.DtsHDPassthrough, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.DtsPassthrough, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.EAc3Passthrough, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.AacPassthru, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.Ac3Passthrough, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.Mp3Passthru, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.TrueHDPassthrough, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.FlacPassthru, sourceTrack, encoders);
                    RemoveIfNotSupported(AudioEncoder.Mp2Passthru, sourceTrack, encoders);
                }

                return(EnumHelper <AudioEncoder> .GetEnumDisplayValuesSubset(encoders));
            }

            if (values.Any() && values.First() != DependencyProperty.UnsetValue)
            {
                return(EnumHelper <AudioEncoder> .GetDisplay((AudioEncoder)values[0]));
            }

            return(EnumHelper <AudioEncoder> .GetDisplay(AudioEncoder.ffaac));
        }
Пример #20
0
 /// <summary>
 /// Setup this tab for the specified preset.
 /// </summary>
 /// <param name="preset">
 /// The preset.
 /// </param>
 /// <param name="task">
 /// The task.
 /// </param>
 public void SetPreset(Preset preset, EncodeTask task)
 {
     this.Task = task;
     this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
     this.NotifyOfPropertyChange(() => this.Chapters);
 }
Пример #21
0
        /// <summary>
        /// Gets a list of Video encoders OR returns the string name of an encoder depending on the input.
        /// </summary>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// IEnumerable VideoEncoder or String encoder name.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Count() >= 2)
            {
                IUserSettingService userSettingService = values[2] as IUserSettingService;
                bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false;
                if (userSettingService != null)
                {
                    isQsvEnabled   = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding);
                    isVceEnabled   = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder);
                    isNvencEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder);
                }

                List <VideoEncoder> allEncoders = values[0] as List <VideoEncoder>;
                EncodeTask          task = values[1] as EncodeTask;

                if (task == null || allEncoders == null)
                {
                    return(null);
                }

                List <VideoEncoder> returnEncoders = new List <VideoEncoder>(allEncoders);

                foreach (var encoder in allEncoders)
                {
                    HBVideoEncoder foundEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(EnumHelper <VideoEncoder> .GetShortName(encoder));
                    if (foundEncoder == null)
                    {
                        returnEncoders.Remove(encoder);
                        continue;
                    }

                    if (task.OutputFormat == OutputFormat.Mp4 && !foundEncoder.SupportsMP4)
                    {
                        returnEncoders.Remove(encoder);
                    }

                    if (task.OutputFormat == OutputFormat.Mkv && !foundEncoder.SupportsMKV)
                    {
                        returnEncoders.Remove(encoder);
                    }

                    if (task.OutputFormat == OutputFormat.WebM && !foundEncoder.SupportsWebM)
                    {
                        returnEncoders.Remove(encoder);
                    }

                    if (!isQsvEnabled && VideoEncoderHelpers.IsQuickSync(encoder))
                    {
                        returnEncoders.Remove(encoder);
                    }

                    if (!isVceEnabled && VideoEncoderHelpers.IsVCN(encoder))
                    {
                        returnEncoders.Remove(encoder);
                    }

                    if (!isNvencEnabled && VideoEncoderHelpers.IsNVEnc(encoder))
                    {
                        returnEncoders.Remove(encoder);
                    }
                }

                return(EnumHelper <VideoEncoder> .GetEnumDisplayValuesSubset(returnEncoders));
            }

            if (values[0].GetType() == typeof(VideoEncoder))
            {
                return(EnumHelper <VideoEncoder> .GetDisplay((VideoEncoder)values[0]));
            }

            return(null);
        }