An Encode Task
Inheritance: Caliburn.Micro.PropertyChangedBase
コード例 #1
0
        /// <summary>
        /// Export a MacGui style plist preset.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="build">
        /// The build.PictureModulusPictureModulus
        /// </param>
        public static void Export(string path, Preset preset, string build)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EncodeTask parsed = new EncodeTask(preset.Task);
            using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented })
            {
                // Header
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteDocType(
                    "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

                xmlWriter.WriteStartElement("plist");
                xmlWriter.WriteStartElement("array");

                // Add New Preset Here. Can write multiple presets here if required in future.
                WritePreset(xmlWriter, parsed, preset, build);

                // Footer
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndDocument();

                // Closeout
                xmlWriter.Close();
            }
        }
コード例 #2
0
        private static string GenerateTabbedComponentsQuery(EncodeTask task, bool filters, int width, int height, int verbose, bool noDvdNav, double x264Step)
        {
            string query = string.Empty;

            // Output Settings
            query += OutputSettingsQuery(task);

            // Filters Panel
            if (filters)
                query += FiltersQuery(task);

            // Picture Settings
            query += PictureSettingsQuery(task, width, height);

            // Video Settings
            query += VideoSettingsQuery(task, x264Step);

            // Audio Settings
            query += AudioSettingsQuery(task);

            // Subtitles Panel
            query += SubtitlesQuery(task);

            // Chapter Markers
            query += ChapterMarkersQuery(task);

            // X264 Panel
            query += X264Query(task);

            // Extra Settings
            query += ExtraSettings(verbose.ToString(), noDvdNav);

            return query;
        }
コード例 #3
0
        /// <summary>
        /// Generate a CLI Query for an EncodeTask Model object
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="previewScanCount">
        /// The preview Scan Count.
        /// </param>
        /// <param name="verbosity">
        /// The verbosity.
        /// </param>
        /// <param name="disableLibDvdNav">
        /// The disable Lib Dvd Nav.
        /// </param>
        /// <returns>
        /// A Cli Query
        /// </returns>
        public static string GenerateQuery(EncodeTask task, int previewScanCount, int verbosity, bool disableLibDvdNav)
        {
            string query = string.Empty;
            query += SourceQuery(task, null, null, previewScanCount);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav);

            return query;
        }
コード例 #4
0
        /// <summary>
        /// Generate a Query for a Preview Encode
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="duration">
        /// The duration.
        /// </param>
        /// <param name="startAtPreview">
        /// The start At Preview.
        /// </param>
        /// <param name="previewScanCount">
        /// The preview Scan Count.
        /// </param>
        /// <param name="verbosity">
        /// The verbosity.
        /// </param>
        /// <param name="disableLibDvdNav">
        /// The disable Lib Dvd Nav.
        /// </param>
        /// <param name="disableQsvDecode">
        /// The disable Qsv Decode.
        /// </param>
        /// <returns>
        /// A Cli query suitable for generating a preview video.
        /// </returns>
        public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview, int previewScanCount, int verbosity, bool disableLibDvdNav, bool disableQsvDecode)
        {
            string query = string.Empty;
            query += SourceQuery(task, duration, startAtPreview, previewScanCount);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav, disableQsvDecode);

            return query;
        }
コード例 #5
0
        /// <summary>
        /// Generate a Query for a Preview Encode
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        /// <param name="duration">
        /// The duration.
        /// </param>
        /// <param name="startAtPreview">
        /// The start At Preview.
        /// </param>
        /// <returns>
        /// A Cli query suitable for generating a preview video.
        /// </returns>
        public static string GeneratePreviewQuery(EncodeTask task, HBConfiguration configuration, int duration, string startAtPreview)
        {
            string query = string.Empty;
            query += SourceQuery(task, duration, startAtPreview, configuration.PreviewScanCount);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, false, false);

            return query;
        }
コード例 #6
0
        /// <summary>
        /// Generate a CLI Query for an EncodeTask Model object
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <returns>
        /// A Cli Query
        /// </returns>
        public static string GenerateQuery(EncodeTask task)
        {
            string query = string.Empty;
            query += SourceQuery(task, null, null);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true);

            return query;
        }
コード例 #7
0
        /// <summary>
        /// Generate a Query for a Preview Encode
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="duration">
        /// The duration.
        /// </param>
        /// <param name="startAtPreview">
        /// The start At Preview.
        /// </param>
        /// <returns>
        /// A Cli query suitable for generating a preview video.
        /// </returns>
        public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview)
        {
            string query = string.Empty;
            query += SourceQuery(task, duration, startAtPreview);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true);

            return query;
        }
コード例 #8
0
        /// <summary>
        /// Generate a CLI Query for an EncodeTask Model object
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        /// <returns>
        /// A Cli Query
        /// </returns>
        public static string GenerateQuery(EncodeTask task, HBConfiguration configuration)
        {
            if (string.IsNullOrEmpty(task.Source))
            {
                return "No source selected";
            }

            string query = string.Empty;
            query += SourceQuery(task, null, null, configuration.PreviewScanCount);
            query += DestinationQuery(task);
            query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, configuration.EnableDxva, configuration.ScalingMode == VideoScaler.BicubicCl);

            return query;
        }
コード例 #9
0
        private static string SourceQuery(EncodeTask task, int mode, int duration, string preview, string previewTotal)
        {
            string query = string.Empty;

            query += string.Format(" -i \"{0}\"", task.Source);
            query += string.Format(" -t {0}", task.Title);
            query += string.Format(" --angle {0}", task.Angle);

            // Decide what part of the video we want to encode.
            switch (task.PointToPointMode)
            {
                case PointToPointMode.Chapters: // Chapters

                    if (task.StartPoint == task.EndPoint)
                        query += string.Format(" -c {0}", task.StartPoint);
                    else
                        query += string.Format(" -c {0}-{1}", task.StartPoint, task.EndPoint);
                    break;
                case PointToPointMode.Seconds: // Seconds
                    int calculatedDuration = task.EndPoint - task.StartPoint;
                    query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", task.StartPoint, calculatedDuration);
                    break;
                case PointToPointMode.Frames: // Frames
                    calculatedDuration = task.EndPoint - task.StartPoint;
                    query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration);
                    break;
                case PointToPointMode.Preview: // Preview
                    query += " --previews " + previewTotal + " ";
                    query += " --start-at-preview " + preview;
                    query += " --stop-at duration:" + duration + " ";
                    break;
                default:
                    break;
            }

            return query;
        }
コード例 #10
0
ファイル: AudioViewModel.cs プロジェクト: seven1240/HandBrake
        /// <summary>
        /// Set the Source Title
        /// </summary>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetSource(Title title, Preset preset, EncodeTask task)
        {
            this.SourceTracks = title.AudioTracks;

            this.SetPreset(preset, task);
            this.AutomaticTrackSelection();
        }
コード例 #11
0
        /// <summary>
        /// Generate the Command Line Arguments for the Subtitles Tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string SubtitlesQuery(EncodeTask task)
        {
            string query = string.Empty;
            if (task.SubtitleTracks.Count != 0)
            {
                // BitMap and CC's
                string subtitleTracks = String.Empty;
                string subtitleForced = String.Empty;
                string subtitleBurn = String.Empty;
                string subtitleDefault = String.Empty;

                // SRT
                string srtFile = String.Empty;
                string srtCodeset = String.Empty;
                string srtOffset = String.Empty;
                string srtLang = String.Empty;
                string srtDefault = String.Empty;
                int srtCount = 0;
                int subCount = 0;

                // Languages
                IDictionary<string, string> langMap = LanguageUtilities.MapLanguages();

                foreach (SubtitleTrack item in task.SubtitleTracks)
                {
                    string itemToAdd;

                    if (item.IsSrtSubtitle) // We have an SRT file
                    {
                        srtCount++; // SRT track id.

                        srtLang += srtLang == string.Empty ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];
                        srtCodeset += srtCodeset == string.Empty ? item.SrtCharCode : "," + item.SrtCharCode;

                        if (item.Default)
                            srtDefault = srtCount.ToString();

                        itemToAdd = item.SrtPath;
                        srtFile += srtFile == string.Empty ? itemToAdd : "," + itemToAdd;

                        itemToAdd = item.SrtOffset.ToString();
                        srtOffset += srtOffset == string.Empty ? itemToAdd : "," + itemToAdd;
                    }
                    else // We have Bitmap or CC
                    {
                        subCount++;

                        // Find --subtitle <string>
                        if (item.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch)
                            itemToAdd = "scan";
                        else
                        {
                            string[] tempSub = item.Track.Split(' ');
                            itemToAdd = tempSub[0];
                        }

                        subtitleTracks += subtitleTracks == string.Empty ? itemToAdd : "," + itemToAdd;

                        // Find --subtitle-forced
                        if (item.Forced)
                            subtitleForced += subtitleForced == string.Empty ? subCount.ToString() : "," + subCount;

                        // Find --subtitle-burn
                        if (item.Burned)
                            subtitleBurn = subCount.ToString();

                        // Find --subtitle-default
                        if (item.Default)
                            subtitleDefault = subCount.ToString();
                    }
                }

                // Build The CLI Subtitles Query
                if (subtitleTracks != string.Empty)
                {
                    query += " --subtitle " + subtitleTracks;

                    if (subtitleForced != string.Empty)
                        query += " --subtitle-forced=" + subtitleForced;
                    if (subtitleBurn != string.Empty)
                        query += " --subtitle-burned=" + subtitleBurn;
                    if (subtitleDefault != string.Empty)
                        query += " --subtitle-default=" + subtitleDefault;
                }

                if (srtFile != string.Empty) // SRTs
                {
                    query += " --srt-file " + "\"" + srtFile + "\"";

                    if (srtCodeset != string.Empty)
                        query += " --srt-codeset " + srtCodeset;
                    if (srtOffset != string.Empty)
                        query += " --srt-offset " + srtOffset;
                    if (srtLang != string.Empty)
                        query += " --srt-lang " + srtLang;
                    if (srtDefault != string.Empty)
                        query += " --srt-default=" + srtDefault;
                }
            }

            return query;
        }
コード例 #12
0
        /// <summary>
        /// Generate the Command Line Arguments for the Output Settings
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string OutputSettingsQuery(EncodeTask task)
        {
            string query = string.Empty;

            query += string.Format(" -f {0} ", EnumHelper<Enum>.GetDescription(task.OutputFormat).ToLower());

            // These are output settings features
            if (task.LargeFile)
                query += " -4 ";

            if (task.IPod5GSupport)
                query += " -I ";

            if (task.OptimizeMP4)
                query += " -O ";

            return query;
        }
コード例 #13
0
        /// <summary>
        /// Generate the Command Line Arguments for the Filters Tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string FiltersQuery(EncodeTask task)
        {
            string query = string.Empty;

            switch (task.Detelecine) // DeTelecine
            {
                case Detelecine.Off:
                    query += string.Empty;
                    break;
                case Detelecine.Default:
                    query += " --detelecine";
                    break;
                case Detelecine.Custom:
                    query += string.Format(" --detelecine=\"{0}\"", task.CustomDetelecine);
                    break;
                default:
                    query += string.Empty;
                    break;
            }

            switch (task.Decomb) // Decomb
            {
                case Decomb.Off:
                    query += string.Empty;
                    break;
                case Decomb.Default:
                    query += " --decomb";
                    break;
                case Decomb.Custom:
                    query += string.Format(" --decomb=\"{0}\"", task.CustomDecomb);
                    break;
                case Decomb.Fast:
                    query += " --decomb=\"fast\"";
                    break;
                case Decomb.Bob:
                    query += " --decomb=\"bob\"";
                    break;
                default:
                    query += string.Empty;
                    break;
            }

            switch (task.Deinterlace) // DeInterlace
            {
                case Deinterlace.Fast:
                    query += " --deinterlace=\"fast\"";
                    break;
                case Deinterlace.Slow:
                    query += " --deinterlace=\"slow\"";
                    break;
                case Deinterlace.Slower:
                    query += " --deinterlace=\"slower\"";
                    break;
                case Deinterlace.Custom:
                    query += string.Format(" --deinterlace=\"{0}\"", task.CustomDeinterlace);
                    break;

                case Deinterlace.Bob:
                    query += " --deinterlace=\"bob\"";
                    break;
                default:
                    query += string.Empty;
                    break;
            }

            switch (task.Denoise) // Denoise
            {
                case Denoise.Weak:
                    query += " --denoise=\"weak\"";
                    break;
                case Denoise.Medium:
                    query += " --denoise=\"medium\"";
                    break;
                case Denoise.Strong:
                    query += " --denoise=\"strong\"";
                    break;
                case Denoise.Custom:
                    query += string.Format(" --denoise=\"{0}\"", task.CustomDenoise);
                    break;
                default:
                    query += string.Empty;
                    break;
            }

            if (task.Deblock != 0)
                query += string.Format(" --deblock={0}", task.Deblock);

            if (task.Grayscale)
                query += " -g ";

            return query;
        }
コード例 #14
0
        /// <summary>
        /// Generate the Command Line Arguments for the Chapter markers tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string ChapterMarkersQuery(EncodeTask task)
        {
            string query = string.Empty;

            // Attach Source name and dvd title to the start of the chapters.csv filename.
            // This is for the queue. It allows different chapter name files for each title.
            string destName = Path.GetFileNameWithoutExtension(task.Destination);
            string sourceTitle = task.Title.ToString();

            if (task.IncludeChapterMarkers && destName != null)
            {
                if (destName.Trim() != String.Empty)
                {
                    string path = sourceTitle != "Automatic"
                                      ? Path.Combine(Path.GetTempPath(), destName + "-" + sourceTitle + "-chapters.csv")
                                      : Path.Combine(Path.GetTempPath(), destName + "-chapters.csv");

                    if (ChapterCsvSave(task.ChapterNames, path) == false)
                        query += " -m ";
                    else
                        query += " --markers=" + "\"" + path + "\"";
                }
                else
                    query += " -m";
            }

            return query;
        }
コード例 #15
0
 /// <summary>
 /// Setup this window for a new source
 /// </summary>
 /// <param name="title">
 /// The title.
 /// </param>
 /// <param name="preset">
 /// The preset.
 /// </param>
 /// <param name="task">
 /// The task.
 /// </param>
 public void SetSource(Title title, Preset preset, EncodeTask task)
 {
 }
コード例 #16
0
        private static string VideoSettingsQuery(EncodeTask task, double x264CqStep)
        {
            string query = string.Empty;

            switch (task.VideoEncoder)
            {
                case VideoEncoder.FFMpeg:
                    query += " -e ffmpeg";
                    break;
                case VideoEncoder.X264:
                    query += " -e x264";
                    break;
                case VideoEncoder.Theora:
                    query += " -e theora";
                    break;
                default:
                    query += " -e x264";
                    break;
            }

            switch (task.VideoEncodeRateType)
            {
                case VideoEncodeRateType.AverageBitrate:
                    if (task.VideoBitrate.HasValue)
                        query += string.Format(" -b {0}", task.VideoBitrate.Value);
                    break;
                case VideoEncodeRateType.ConstantQuality:
                    double value;
                    switch (task.VideoEncoder)
                    {
                        case VideoEncoder.FFMpeg:
                            value = 31 - (task.Quality.Value - 1);
                            query += string.Format(" -q {0}", value.ToString(new CultureInfo("en-US")));
                            break;
                        case VideoEncoder.X264:
                            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
                            value = 51 - (task.Quality.Value * x264CqStep);
                            value = Math.Round(value, 2);
                            query += string.Format(" -q {0}", value.ToString(culture));
                            break;
                        case VideoEncoder.Theora:
                            value = task.Quality.Value;
                            query += string.Format(" -q {0}", value.ToString(new CultureInfo("en-US")));
                            break;
                    }
                    break;

            }

            if (task.TwoPass)
                query += " -2 ";

            if (task.TurboFirstPass)
                query += " -T ";

            if (task.Framerate.HasValue)
                query += string.Format(" -r {0}", task.Framerate);

            switch (task.FramerateMode)
            {
                case FramerateMode.CFR:
                    query += " --cfr";
                    break;
                case FramerateMode.VFR:
                    query += " --vfr";
                    break;
                case FramerateMode.PFR:
                    query += " --pfr";
                    break;
                default:
                    query += " --vfr";
                    break;
            }

            return query;
        }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueTask"/> class.
 /// </summary>
 /// <param name="task">
 /// The task.
 /// </param>
 /// <param name="configuration">
 /// The configuration.
 /// </param>
 public QueueTask(EncodeTask task, HBConfiguration configuration)
 {
     this.Task          = task;
     this.Configuration = configuration;
     this.Status        = QueueItemStatus.Waiting;
 }
コード例 #18
0
ファイル: AutoNameHelper.cs プロジェクト: newfront/HandBrake
        /// <summary>
        /// Function which generates the filename and path automatically based on 
        /// the Source Name, DVD title and DVD Chapters
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="sourceOrLabelName">
        /// The Source or Label Name
        /// </param>
        /// <returns>
        /// The Generated FileName
        /// </returns>
        public static string AutoName(EncodeTask task, string sourceOrLabelName)
        {
            string autoNamePath = string.Empty;
            if (task.Title != 0) // TODO check.
            {
                // Get the Source Name and remove any invalid characters
                string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));
                sourceName = Path.GetFileNameWithoutExtension(sourceName);

                // Remove Underscores
                if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
                    sourceName = sourceName.Replace("_", " ");

                // Switch to "Title Case"
                if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase))
                    sourceName = sourceName.ToTitleCase();

                // 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;

                /*
                 * File Name
                 */
                string destinationFilename;
                if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != string.Empty)
                {
                    destinationFilename = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat);
                    destinationFilename = destinationFilename.Replace("{source}", sourceName)
                                                             .Replace("{title}", dvdTitle)
                                                             .Replace("{chapters}", combinedChapterTag)
                                                             .Replace("{date}", DateTime.Now.Date.ToShortDateString().Replace('/', '-'));
                }
                else
                    destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;

                /*
                 * File Extension
                 */
                if (task.OutputFormat == OutputFormat.Mp4 || task.OutputFormat == OutputFormat.M4V)
                {
                    switch (userSettingService.GetUserSetting<int>(UserSettingConstants.UseM4v))
                    {
                        case 0: // Automatic
                            destinationFilename += task.IncludeChapterMarkers || task.RequiresM4v ? ".m4v" : ".mp4";
                            break;
                        case 1: // Always MP4
                            destinationFilename += ".mp4";
                            break;
                        case 2: // Always M4V
                            destinationFilename += ".m4v";
                            break;
                    }
                }
                else if (task.OutputFormat == OutputFormat.Mkv)
                    destinationFilename += ".mkv";

                /*
                 * File Destination Path
                 */

                // If there is an auto name path, use it...
                if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source))
                {
                    string savedPath = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty);

                    string directory = Directory.Exists(task.Source)
                                           ? task.Source
                                           : Path.GetDirectoryName(task.Source);
                    string requestedPath = Path.Combine(directory, savedPath);

                    autoNamePath = Path.Combine(requestedPath, destinationFilename);
                    if (autoNamePath == task.Source)
                    {
                        // Append out_ to files that already exist or is the source file
                        autoNamePath = Path.Combine(Path.GetDirectoryName(task.Source), "output_" + destinationFilename);
                    }
                }
                else if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !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 = Path.Combine(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder), destinationFilename);
                    }
                }
                else if (!task.Destination.Contains(Path.DirectorySeparatorChar.ToString()))
                {
                    // Third case: If the destination box doesn't already contain a path, make one.
                    if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim() != string.Empty &&
                        userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim() != "Click 'Browse' to set the default location")
                    {
                        autoNamePath = Path.Combine(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath), destinationFilename);
                    }
                    else // ...otherwise, output to the source directory
                        autoNamePath = null;
                }
                else // Otherwise, use the path that is already there.
                {
                    // Use the path and change the file extension to match the previous destination
                    autoNamePath = Path.Combine(Path.GetDirectoryName(task.Destination), destinationFilename);
                }
            }

            return autoNamePath;
        }
コード例 #19
0
ファイル: PresetLoader.cs プロジェクト: bakotaco/HandBrake
        /// <summary>
        /// This function takes in a Query which has been parsed by QueryParser and
        /// set's all the GUI widgets correctly.
        /// </summary>
        /// <param name="mainWindow">
        /// FrmMain window
        /// </param>
        /// <param name="presetQuery">
        /// The Parsed CLI Query
        /// </param>
        /// <param name="name">
        /// Name of the preset
        /// </param>
        public static void LoadPreset(frmMain mainWindow, EncodeTask presetQuery, string name)
        {
            #region Source

            // Reset some vaules to stock first to prevent errors.
            mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;

            // Now load all the new settings onto the main window
            string destination = mainWindow.text_destination.Text;
            destination = destination.Replace(".mp4", "." + presetQuery.OutputFormat);
            destination = destination.Replace(".m4v", "." + presetQuery.OutputFormat);
            destination = destination.Replace(".mkv", "." + presetQuery.OutputFormat);
            mainWindow.text_destination.Text = destination;

            #endregion

            #region Destination and Output Settings

            if (presetQuery.OutputFormat == OutputFormat.Mp4 || presetQuery.OutputFormat == OutputFormat.M4V)
            {
                if (mainWindow.drop_format.SelectedIndex == 0)
                {
                    mainWindow.SetExtension(".mp4");
                }
                else
                {
                    mainWindow.drop_format.SelectedIndex = 0;
                }
            }
            else if (presetQuery.OutputFormat == OutputFormat.Mkv)
            {
                if (mainWindow.drop_format.SelectedIndex == 1)
                {
                    mainWindow.SetExtension(".mkv");
                }
                else
                {
                    mainWindow.drop_format.SelectedIndex = 1;
                }
            }

            mainWindow.check_iPodAtom.CheckState = presetQuery.IPod5GSupport ? CheckState.Checked : CheckState.Unchecked;

            mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4
                                                          ? CheckState.Checked
                                                          : CheckState.Unchecked;

            mainWindow.check_largeFile.CheckState = presetQuery.LargeFile ? CheckState.Checked : CheckState.Unchecked;

            mainWindow.setContainerOpts(); // select the container options according to the selected format

            #endregion

            #region Picture

            mainWindow.PictureSettings.check_autoCrop.Checked = true;
            if (presetQuery.IsCustomCropping)
            {
                mainWindow.PictureSettings.check_customCrop.Checked = true;
                mainWindow.PictureSettings.crop_top.Value = presetQuery.Cropping.Top;
                mainWindow.PictureSettings.crop_bottom.Value = presetQuery.Cropping.Bottom;
                mainWindow.PictureSettings.crop_left.Value = presetQuery.Cropping.Left;
                mainWindow.PictureSettings.crop_right.Value = presetQuery.Cropping.Right;
            }

            // Set the anamorphic mode 0,1,2,3

            switch (presetQuery.Anamorphic)
            {
                case Anamorphic.None:
                    mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 0;
                    break;
                case Anamorphic.Strict:
                    mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 1;
                    break;
                case Anamorphic.Loose:
                    mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 2;
                    break;
                case Anamorphic.Custom:
                    mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 3;
                    break;
            }

            // Keep Aspect Ration Anamorphic Setting.
            mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.KeepDisplayAspect
                                                                     ? CheckState.Checked
                                                                     : CheckState.Unchecked;

            // Set the Width and height as Required.
            if (presetQuery.Width.HasValue)
            {
                mainWindow.PictureSettings.text_width.Value = presetQuery.Width.Value;
            }

            if (presetQuery.Height.HasValue)
            {
                mainWindow.PictureSettings.text_height.Value = presetQuery.Height.Value;
            }

            // Max Width/Height override Width/Height
            if (presetQuery.MaxWidth.HasValue)
            {
                mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth.Value;
            }

            if (presetQuery.MaxHeight.HasValue)
            {
                mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight.Value;
            }

            if (presetQuery.MaxHeight.HasValue && presetQuery.MaxWidth.HasValue)
            {
                mainWindow.PictureSettings.PresetMaximumResolution = new Size(
                    presetQuery.MaxWidth.Value, presetQuery.MaxHeight.Value);
            }

            // Case where both height and max height are 0 - For built-in presets
            if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0)
            {
                mainWindow.PictureSettings.text_height.Value = 0;
            }

            if (presetQuery.MaxWidth == 0 && presetQuery.Width == 0)
            {
                if (mainWindow.selectedTitle != null && mainWindow.selectedTitle.Resolution.Width != 0)
                {
                    mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width;
                }
            }

            // Aspect Ratio for non anamorphic sources
            if (presetQuery.Anamorphic == Anamorphic.None)
            {
                mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.Height == 0
                                                                         ? CheckState.Checked
                                                                         : CheckState.Unchecked;
            }

            // Custom Anamorphic Controls
            mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.DisplayWidth.ToString();
            mainWindow.PictureSettings.updownParHeight.Text = presetQuery.PixelAspectY.ToString();
            mainWindow.PictureSettings.updownParWidth.Text = presetQuery.PixelAspectX.ToString();
            mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.Modulus.ToString();

            #endregion

            #region Filters

            mainWindow.Filters.SetDecomb(presetQuery.Decomb, presetQuery.CustomDecomb);
            mainWindow.Filters.SetDeInterlace(presetQuery.Deinterlace, presetQuery.CustomDeinterlace);
            mainWindow.Filters.SetDeNoise(presetQuery.Denoise, presetQuery.CustomDenoise);
            mainWindow.Filters.SetDeTelecine(presetQuery.Detelecine, presetQuery.CustomDetelecine);
            mainWindow.Filters.SetDeBlock(presetQuery.Deblock);
            mainWindow.Filters.SetGrayScale(presetQuery.Grayscale);

            #endregion

            #region Video

            switch (presetQuery.VideoEncoder)
            {
                case VideoEncoder.X264:
                    mainWindow.drp_videoEncoder.SelectedIndex = 1;
                    break;
                case VideoEncoder.FFMpeg:
                    mainWindow.drp_videoEncoder.SelectedIndex = 0;
                    break;
                case VideoEncoder.Theora:
                    mainWindow.drp_videoEncoder.SelectedIndex = 2;
                    break;
            }

            if (presetQuery.VideoBitrate != null)
            {
                mainWindow.radio_avgBitrate.Checked = true;
                mainWindow.text_bitrate.Text = presetQuery.VideoBitrate.ToString();
            }

            // Quality
            if (presetQuery.Quality != null)
            {
                mainWindow.radio_cq.Checked = true;
                mainWindow.slider_videoQuality.Value = QualityToSliderValue(
                    presetQuery.VideoEncoder, presetQuery.Quality);
            }

            mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;

            if (presetQuery.Framerate != null)
            {
                mainWindow.drp_videoFramerate.Text = presetQuery.Framerate.ToString();
            }
            else
            {
                mainWindow.drp_videoFramerate.SelectedIndex = 0;
            }

            if (presetQuery.Framerate != null)
            {
                // Constant or Peak Framerate for a set framerate.

                if (presetQuery.FramerateMode == FramerateMode.CFR)
                    mainWindow.radio_constantFramerate.Checked = true;
                else
                    mainWindow.radio_peakAndVariable.Checked = true;
            }
            else
            {
                // Constant or Variable Framerate for Same as Source.
                if (presetQuery.FramerateMode == FramerateMode.CFR)
                    mainWindow.radio_constantFramerate.Checked = true;
                else
                    mainWindow.radio_peakAndVariable.Checked = true;
            }

            mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;

            #endregion

            #region Chapter Markers

            if (presetQuery.IncludeChapterMarkers)
            {
                mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;
                mainWindow.Check_ChapterMarkers.Enabled = true;
            }
            else
            {
                mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;
            }

            #endregion

            #region Audio

            mainWindow.AudioSettings.LoadTracks(presetQuery.AudioTracks);

            #endregion

            #region Other

            mainWindow.x264Panel.X264Query = presetQuery.AdvancedEncoderOptions;

            // Set the preset name
            mainWindow.labelPreset.Text = "Output Settings (Preset: " + name + ")";

            #endregion
        }
コード例 #20
0
 private static string X264Query(EncodeTask task)
 {
     return string.IsNullOrEmpty(task.AdvancedEncoderOptions) ? string.Empty : string.Format(" -x {0}", task.AdvancedEncoderOptions);
 }
コード例 #21
0
        /// <summary>
        /// Generate the Command Line Arguments for the Audio Settings Tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string AudioSettingsQuery(EncodeTask task)
        {
            string query = string.Empty;

            ObservableCollection<AudioTrack> audioTracks = task.AudioTracks;

            List<int> tracks = new List<int>();
            List<AudioEncoder> codecs = new List<AudioEncoder>();
            List<Mixdown> mixdowns = new List<Mixdown>();
            List<double> samplerates = new List<double>();
            List<int> bitrates = new List<int>();
            List<double> drcs = new List<double>();
            List<double> gains = new List<double>();
            List<string> trackNames = new List<string>();

            // No Audio
            if (audioTracks.Count == 0)
                query += " -a none ";

            // Gather information about each audio track and store them in the declared lists.
            foreach (AudioTrack track in audioTracks)
            {
                if (track.Track == null)
                {
                    continue;
                }

                tracks.Add(track.Track.Value);

                // Audio Codec (-E)
                codecs.Add(track.Encoder);

                // Audio Mixdown (-6)
                mixdowns.Add(track.IsPassthru ? Mixdown.None : track.MixDown);

                // Sample Rate (-R)
                samplerates.Add(track.IsPassthru ? 0 : track.SampleRate);

                // Audio Bitrate (-B)
                bitrates.Add(track.IsPassthru ? 0 : track.Bitrate);

                // DRC (-D)
                drcs.Add(track.IsPassthru ? 0 : track.DRC);

                // Gain (--gain)
                gains.Add(track.IsPassthru ? 0 : track.Gain);

                // Audio Track Name (--aname)
                trackNames.Add(track.TrackName);
            }

            // Audio Track (-a)
            string audioItems = string.Empty;
            bool firstLoop = true;

            foreach (int item in tracks)
            {
                if (firstLoop)
                {
                    audioItems = item.ToString();
                    firstLoop = false;
                }
                else
                    audioItems += "," + item;
            }
            if (audioItems.Trim() != String.Empty)
                query += " -a " + audioItems;
            firstLoop = true;
            audioItems = string.Empty; // Reset for another pass.

            // Audio Codec (-E)
            foreach (AudioEncoder item in codecs)
            {
                if (firstLoop)
                {
                    audioItems = Converters.GetCliAudioEncoder(item);
                    firstLoop = false;
                }
                else
                    audioItems += "," +  Converters.GetCliAudioEncoder(item);
            }
            if (audioItems.Trim() != String.Empty)
                query += " -E " + audioItems;
            firstLoop = true;
            audioItems = string.Empty; // Reset for another pass.

            // Audio Mixdown (-6)
            foreach (Mixdown item in mixdowns)
            {
                if (firstLoop)
                {
                    audioItems = Converters.GetCliMixDown(item);
                    firstLoop = false;
                }
                else
                    audioItems += "," + Converters.GetCliMixDown(item);
            }
            if (audioItems.Trim() != String.Empty)
                query += " -6 " + audioItems;
            firstLoop = true;
            audioItems = string.Empty; // Reset for another pass.

            // Sample Rate (-R)
            foreach (double item in samplerates)
            {
                string add = (item == 0.0) ? "Auto" : item.ToString();
                if (firstLoop)
                {
                    audioItems = add;
                    firstLoop = false;
                }
                else
                    audioItems += "," + add;
            }
            if (audioItems.Trim() != String.Empty)
                query += " -R " + audioItems;
            firstLoop = true;
            audioItems = string.Empty; // Reset for another pass.

            // Audio Bitrate (-B)
            foreach (int item in bitrates)
            {
                if (firstLoop)
                {
                    audioItems = item.ToString();
                    firstLoop = false;
                }
                else
                    audioItems += "," + item;
            }
            if (audioItems.Trim() != String.Empty)
                query += " -B " + audioItems;
            firstLoop = true;
            audioItems = string.Empty; // Reset for another pass.

            // DRC (-D)
            foreach (var itm in drcs)
            {
                string item = itm.ToString(new CultureInfo("en-US"));
                if (firstLoop)
                {
                    audioItems = item;
                    firstLoop = false;
                }
                else
                    audioItems += "," + item;
            }
            if (audioItems.Trim() != String.Empty)
                query += " -D " + audioItems;

            audioItems = string.Empty; // Reset for another pass.
            firstLoop = true;

            // Gain (--gain)
            foreach (var itm in gains)
            {
                string item = itm.ToString(new CultureInfo("en-US"));
                if (firstLoop)
                {
                    audioItems = item;
                    firstLoop = false;
                }
                else
                    audioItems += "," + item;
            }
            if (audioItems.Trim() != String.Empty)
                query += " --gain " + audioItems;

            audioItems = string.Empty; // Reset for another pass.
            firstLoop = true;

            // Audio Track Names (--aname)
            bool foundTrackName = false;
            foreach (string trackName in trackNames)
            {
                if (!string.IsNullOrEmpty(trackName))
                {
                    foundTrackName = true;
                }

                if (firstLoop)
                {
                    audioItems = string.IsNullOrEmpty(trackName) ? "\"\"" : string.Format("\"{0}\"", trackName.Trim());
                    firstLoop = false;
                }
                else
                    audioItems += "," + (string.IsNullOrEmpty(trackName) ? "\"\"" : string.Format("\"{0}\"", trackName.Trim()));
            }
            if (foundTrackName)
                query += string.Format(" --aname={0}", audioItems);

            // Passthru Settings
            if (task.AllowedPassthruOptions != null)
            {
                string fallbackEncoders = string.Empty;

                if (task.AllowedPassthruOptions.AudioAllowAACPass != null && task.AllowedPassthruOptions.AudioAllowAACPass.Value)
                {
                    fallbackEncoders += "aac";
                }

                if (task.AllowedPassthruOptions.AudioAllowAC3Pass != null && task.AllowedPassthruOptions.AudioAllowAC3Pass.Value)
                {
                    fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "ac3" : ",ac3";
                }

                if (task.AllowedPassthruOptions.AudioAllowDTSHDPass != null && task.AllowedPassthruOptions.AudioAllowDTSHDPass.Value)
                {
                    fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dtshd" : ",dtshd";
                }

                if (task.AllowedPassthruOptions.AudioAllowDTSPass != null && task.AllowedPassthruOptions.AudioAllowDTSPass.Value)
                {
                    fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dts" : ",dts";
                }

                if (task.AllowedPassthruOptions.AudioAllowMP3Pass != null && task.AllowedPassthruOptions.AudioAllowMP3Pass.Value)
                {
                    fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "mp3" : ",mp3";
                }

                if (!string.IsNullOrEmpty(fallbackEncoders))
                {
                    // Special Case, The CLI alredy defaults to ALL, so if all area selected, then just set copy-mask to none
                    if (fallbackEncoders == "aac,ac3,dtshd,dts,mp3")
                    {
                        query += string.Format(" --audio-copy-mask none");
                    }
                    else
                    {
                        query += string.Format(" --audio-copy-mask {0}", fallbackEncoders);
                    }
                }
                else
                {
                    query += string.Format(" --audio-copy-mask none");
                }

                query += string.Format(" --audio-fallback {0}", Converters.GetCliAudioEncoder(task.AllowedPassthruOptions.AudioEncoderFallback));
            }

            return query;
        }
コード例 #22
0
        /// <summary>
        /// Takes in a query which can be in any order and parses it. 
        /// All varibles are then set so they can be used elsewhere.
        /// </summary>
        /// <param name="input">A ClI Query</param>
        /// <returns>A Parsed Query</returns>
        public static EncodeTask Parse(string input)
        {
            var parsed = new EncodeTask();

            #region Regular Expressions

            // Source
            Match title = Regex.Match(input, @"-t ([0-9]*)");
            Match chapters = Regex.Match(input, @"-c ([0-9-]*)");

            // Output Settings
            Match format = Regex.Match(input, @"-f ([a-zA-Z0-9]*)");
            Match grayscale = Regex.Match(input, @" -g");
            Match largerMp4 = Regex.Match(input, @" -4");
            Match ipodAtom = Regex.Match(input, @" -I");

            // Picture Settings Tab
            Match width = Regex.Match(input, @"-w ([0-9]*)");
            Match height = Regex.Match(input, @"-l ([0-9]*)");
            Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
            Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
            Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");

            Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");
            Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");
            Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");

            Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");
            Match displayWidth = Regex.Match(input, @"--display-width ([0-9]*)");
            Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");
            Match modulus = Regex.Match(input, @"--modulus ([0-9]*)");

            // Picture Settings - Filters
            Match decomb = Regex.Match(input, @" --decomb");
            Match decombValue = Regex.Match(input, @" --decomb=\""([a-zA-Z0-9.:]*)\""");
            Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\""");
            Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\""");
            Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)");
            Match detelecine = Regex.Match(input, @"--detelecine");
            Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");

            // Video Settings Tab
            Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
            Match videoFramerate = Regex.Match(input, @"-r ([0-9.]*)");
            Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
            Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
            Match twoPass = Regex.Match(input, @" -2");
            Match turboFirstPass = Regex.Match(input, @" -T");
            Match optimizeMP4 = Regex.Match(input, @" -O");
            Match pfr = Regex.Match(input, @" --pfr");
            Match vfr = Regex.Match(input, @" --vfr");
            Match cfr = Regex.Match(input, @" --cfr");

            // Audio Settings Tab
            Match noAudio = Regex.Match(input, @"-a none");
            Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)");
            Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)");
            Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,:]*)");
            Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)"); // Auto = a-z
            Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z
            Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");
            Match gainValues = Regex.Match(input, @"--gain=([0-9.,-]*)");

            // Chapters Tab
            Match chapterMarkers = Regex.Match(input, @" -m");
            Match chapterMarkersFileMode = Regex.Match(input, @"--markers");

            // Advanced Tab
            Match advanced = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");

            #endregion

            #region Set Varibles

            try
            {
                #region Source Tab

                if (title.Success)
                {
                    parsed.Title = int.Parse(title.ToString().Replace("-t ", string.Empty));
                }

                if (chapters.Success)
                {
                    parsed.PointToPointMode = PointToPointMode.Chapters;
                    string[] actTitles = chapters.ToString().Replace("-c ", string.Empty).Split('-');
                    parsed.StartPoint = int.Parse(actTitles[0]);
                    if (actTitles.Length > 1)
                    {
                        parsed.EndPoint = int.Parse(actTitles[1]);
                    }

                    if ((parsed.StartPoint == 1) && (parsed.EndPoint == 0))
                    {
                        parsed.EndPoint = parsed.StartPoint;
                    }
                }
             
                #endregion

                #region Output Settings

                if (format.Success)
                {
                    parsed.OutputFormat = Converters.GetFileFormat(format.Groups[1].ToString());
                }
                parsed.LargeFile = largerMp4.Success;
                parsed.IPod5GSupport = ipodAtom.Success;
                parsed.OptimizeMP4 = optimizeMP4.Success;

                #endregion

                #region Picture Tab

                if (width.Success)
                    parsed.Width = int.Parse(width.Groups[0].Value.Replace("-w ", string.Empty));

                if (height.Success)
                    parsed.Height = int.Parse(height.Groups[0].Value.Replace("-l ", string.Empty));

                if (maxWidth.Success)
                    parsed.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", string.Empty));

                if (maxHeight.Success)
                    parsed.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", string.Empty));

                if (crop.Success)
                {
                    try
                    {
                        string values = crop.ToString().Replace("--crop ", string.Empty);
                        string[] actCropValues = values.Split(':');
                        parsed.Cropping = new Cropping(
                            int.Parse(actCropValues[0]),
                            int.Parse(actCropValues[1]),
                            int.Parse(actCropValues[2]),
                            int.Parse(actCropValues[3]));
                    }
                    catch (Exception)
                    {
                        // No need to do anything.
                    }
                }

                if (strictAnamorphic.Success)
                    parsed.Anamorphic = Anamorphic.Strict;
                else if (looseAnamorphic.Success)
                    parsed.Anamorphic = Anamorphic.Loose;
                else if (customAnamorphic.Success)
                    parsed.Anamorphic = Anamorphic.Custom;
                else
                    parsed.Anamorphic = Anamorphic.None;

                parsed.KeepDisplayAspect = keepDisplayAsect.Success;

                if (displayWidth.Success)
                    parsed.DisplayWidth =
                        double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", string.Empty), Culture);

                if (pixelAspect.Success)
                    parsed.PixelAspectX = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", string.Empty));

                if (pixelAspect.Success && pixelAspect.Groups.Count >= 3)
                    parsed.PixelAspectY = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", string.Empty));

                if (modulus.Success)
                    parsed.Modulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", string.Empty));

                #endregion

                #region Filters

                parsed.Decomb = Decomb.Off;
                if (decomb.Success)
                {
                    parsed.Decomb = Decomb.Default;
                    if (decombValue.Success)
                    {
                        parsed.CustomDecomb = decombValue.ToString().Replace("--decomb=", string.Empty).Replace("\"", string.Empty);
                    }
                }

                parsed.Deinterlace = Deinterlace.Off;
                if (deinterlace.Success)
                {
                    switch (deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty).ToLower())
                    {
                        case "fast":
                            parsed.Deinterlace = Deinterlace.Fast;
                            break;
                        case "slow":
                            parsed.Deinterlace = Deinterlace.Slow;
                            break;
                        case "slower":
                            parsed.Deinterlace = Deinterlace.Slower;
                            break;
                        default:
                            parsed.Deinterlace = Deinterlace.Custom;
                            parsed.CustomDeinterlace = deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty).ToLower();
                            break;
                    }
                }

                parsed.Denoise = Denoise.Off;
                if (denoise.Success)
                {
                    switch (denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty))
                    {
                        case "weak":
                            parsed.Denoise = Denoise.Weak;
                            break;
                        case "medium":
                            parsed.Denoise = Denoise.Medium;
                            break;
                        case "strong":
                            parsed.Denoise = Denoise.Strong;
                            break;
                        default:
                            parsed.Denoise = Denoise.Custom;
                            parsed.CustomDenoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty);
                            break;
                    }
                }

                parsed.Deblock = 0;
                if (deblock.Success)
                {
                    int dval;
                    int.TryParse(deblock.ToString().Replace("--deblock=", string.Empty), out dval);
                    parsed.Deblock = dval;
                }

                parsed.Detelecine = Detelecine.Off;
                if (detelecine.Success)
                {
                    parsed.Detelecine = Detelecine.Default;
                    if (detelecineValue.Success)
                    {
                        parsed.CustomDetelecine = detelecineValue.ToString().Replace("--detelecine=", string.Empty).Replace("\"", string.Empty);
                        parsed.Detelecine = Detelecine.Custom;
                    }
                }

                #endregion

                #region Video Settings Tab

                parsed.VideoEncoder = Converters.GetVideoEncoder(videoEncoder.ToString().Replace("-e ", string.Empty));

                if (videoFramerate.Success)
                {
                    double fps;
                    double.TryParse(videoFramerate.Groups[1].ToString(), out fps);
                    parsed.Framerate = fps;
                }

                if (pfr.Success)
                    parsed.FramerateMode = FramerateMode.PFR;
                else if (cfr.Success)
                    parsed.FramerateMode = FramerateMode.CFR;
                else
                    parsed.FramerateMode = FramerateMode.VFR; // Default to VFR

                parsed.Grayscale = grayscale.Success;
                parsed.TwoPass = twoPass.Success;
                parsed.TurboFirstPass = turboFirstPass.Success;

                if (videoBitrate.Success)
                {
                    parsed.VideoEncodeRateType = VideoEncodeRateType.AverageBitrate;
                    parsed.VideoBitrate = int.Parse(videoBitrate.ToString().Replace("-b ", string.Empty));
                }

                if (videoQuality.Success)
                {
                    float quality = float.Parse(videoQuality.ToString().Replace("-q ", string.Empty), Culture);
                    parsed.Quality = quality;
                }

                #endregion

                #region Audio Tab

                // Find out how many tracks we need to add by checking how many encoders or audio tracks are selected.
                int encoderCount = 0;
                if (audioEncoders.Success)
                {
                    string[] audioDataCounters = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');
                    encoderCount = audioDataCounters.Length;
                }

                // Get the data from the regular expression results
                string[] trackData = null;
                string[] trackMixes = null;
                string[] trackEncoders = null;
                string[] trackBitrates = null;
                string[] trackSamplerates = null;
                string[] trackDRCvalues = null;
                string[] trackGainValues = null;

                if (audioTracks.Success)
                    trackData = audioTracks.ToString().Replace("-a ", string.Empty).Split(',');
                if (audioTrackMixes.Success)
                    trackMixes = audioTrackMixes.ToString().Replace("-6 ", string.Empty).Split(',');
                if (audioEncoders.Success)
                    trackEncoders = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');
                if (audioBitrates.Success)
                    trackBitrates = audioBitrates.ToString().Replace("-B ", string.Empty).Split(',');
                if (audioSampleRates.Success)
                    trackSamplerates = audioSampleRates.ToString().Replace("-R ", string.Empty).Split(',');
                if (drcValues.Success)
                    trackDRCvalues = drcValues.ToString().Replace("-D ", string.Empty).Split(',');
                if (gainValues.Success)
                    trackGainValues = gainValues.ToString().Replace("--gain=", string.Empty).Split(',');

                // Create new Audio Track Classes and store them in the ArrayList
                List<AudioTrack> allAudioTrackInfo = new List<AudioTrack>();
                for (int x = 0; x < encoderCount; x++)
                {
                    AudioTrack track = new AudioTrack();
                    //if (trackData != null)
                    //    if (trackData.Length >= (x + 1)) // Audio Track
                    //        track.ScannedTrack = trackData[x].Trim();

                    if (trackMixes != null)
                        if (trackMixes.Length >= (x + 1)) // Audio Mix
                            track.MixDown = Converters.GetAudioMixDown(Converters.GetMixDown(trackMixes[x].Trim()));

                    if (trackEncoders != null)
                        if (trackEncoders.Length >= (x + 1)) // Audio Mix
                            track.Encoder = Converters.GetAudioEncoderFromCliString(trackEncoders[x].Trim());

                    if (trackBitrates != null)
                        if (trackBitrates.Length >= (x + 1)) // Audio Encoder
                            track.Bitrate = int.Parse(trackBitrates[x].Trim() == "auto" ? "0" : trackBitrates[x].Trim());

                    if (trackSamplerates != null)
                        if (trackSamplerates.Length >= (x + 1)) // Audio SampleRate
                            track.SampleRate = double.Parse(trackSamplerates[x].Replace("Auto", "0").Trim(), Culture);

                    if (trackDRCvalues != null)
                        if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values
                            track.DRC = double.Parse(trackDRCvalues[x].Trim(), Culture);

                    if (trackGainValues != null)
                        if (trackGainValues.Length >= (x + 1)) // Audio DRC Values
                            track.Gain = int.Parse(trackGainValues[x].Trim());

                    allAudioTrackInfo.Add(track);
                }

                parsed.AudioTracks = allAudioTrackInfo;

                #endregion

                #region Chapters Tab

                if (chapterMarkersFileMode.Success || chapterMarkers.Success)
                    parsed.IncludeChapterMarkers = true;

                #endregion

                #region Advanced and other

                if (advanced.Success)
                    parsed.AdvancedEncoderOptions = advanced.ToString().Replace("-x ", string.Empty);

                #endregion
            }
            catch (Exception exc)
            {
                throw new Exception("An error has occured in the QueryParser Utility.", exc);
            }

            #endregion

            return parsed;
        }
コード例 #23
0
        /// <summary>
        /// Generate the Command Line Arguments for the Destination File
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string DestinationQuery(EncodeTask task)
        {
            string query = string.Empty;

            if (task.PointToPointMode == PointToPointMode.Preview)
                query += string.Format(" -o \"{0}\" ", task.Destination.Replace(".m", "_sample.m"));
            else
                query += string.Format(" -o \"{0}\" ", task.Destination);

            return query;
        }
コード例 #24
0
ファイル: EncodeTask.cs プロジェクト: Eddy805/HandBrake
        /// <summary>
        /// Initializes a new instance of the <see cref="EncodeTask"/> class. 
        /// Copy Constructor
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        public EncodeTask(EncodeTask task)
        {
            this.AdvancedEncoderOptions = task.AdvancedEncoderOptions;
            this.AllowedPassthruOptions = new AllowedPassthru(task.AllowedPassthruOptions);
            this.Anamorphic = task.Anamorphic;
            this.Angle = task.Angle;

            this.AudioTracks = new ObservableCollection<AudioTrack>();
            foreach (AudioTrack track in task.AudioTracks)
            {
                this.AudioTracks.Add(new AudioTrack(track));
            }

            this.ChapterNames = new ObservableCollection<ChapterMarker>();
            foreach (ChapterMarker track in task.ChapterNames)
            {
                this.ChapterNames.Add(new ChapterMarker(track));
            }

            this.ChapterMarkersFilePath = task.ChapterMarkersFilePath;
            this.Cropping = new Cropping(task.Cropping);
            this.CustomDecomb = task.CustomDecomb;
            this.CustomDeinterlace = task.CustomDeinterlace;
            this.CustomDenoise = task.CustomDenoise;
            this.CustomDetelecine = task.CustomDetelecine;
            this.Deblock = task.Deblock;
            this.Decomb = task.Decomb;
            this.Deinterlace = task.Deinterlace;
            this.Denoise = task.Denoise;
            this.Destination = task.Destination;
            this.Detelecine = task.Detelecine;
            this.DisableLibDvdNav = task.DisableLibDvdNav;
            this.DisplayWidth = task.DisplayWidth;
            this.EndPoint = task.EndPoint;
            this.Framerate = task.Framerate;
            this.FramerateMode = task.FramerateMode;
            this.Grayscale = task.Grayscale;
            this.HasCropping = task.HasCropping;
            this.Height = task.Height;
            this.IncludeChapterMarkers = task.IncludeChapterMarkers;
            this.IPod5GSupport = task.IPod5GSupport;
            this.KeepDisplayAspect = task.KeepDisplayAspect;
            this.LargeFile = task.LargeFile;
            this.MaxHeight = task.MaxHeight;
            this.MaxWidth = task.MaxWidth;
            this.Modulus = task.Modulus;
            this.OptimizeMP4 = task.OptimizeMP4;
            this.OutputFormat = task.OutputFormat;
            this.PixelAspectX = task.PixelAspectX;
            this.PixelAspectY = task.PixelAspectY;
            this.PointToPointMode = task.PointToPointMode;
            this.PresetBuildNumber = task.PresetBuildNumber;
            this.PresetDescription = task.PresetDescription;
            this.PresetName = task.PresetName;
            this.Quality = task.Quality;
            this.Source = task.Source;
            this.StartPoint = task.StartPoint;

            this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
            foreach (SubtitleTrack subtitleTrack in task.SubtitleTracks)
            {
                this.SubtitleTracks.Add(new SubtitleTrack(subtitleTrack));
            }

            this.Title = task.Title;
            this.TurboFirstPass = task.TurboFirstPass;
            this.TwoPass = task.TwoPass;
            this.Type = task.Type;
            this.UsesMaxPictureSettings = task.UsesMaxPictureSettings;
            this.UsesPictureFilters = task.UsesPictureFilters;
            this.UsesPictureSettings = task.UsesPictureSettings;
            this.Verbosity = task.Verbosity;
            this.VideoBitrate = task.VideoBitrate;
            this.VideoEncoder = task.VideoEncoder;
            this.VideoEncodeRateType = task.VideoEncodeRateType;
            this.Width = task.Width;
            this.x264Preset = task.x264Preset;
            this.x264Profile = task.x264Profile;
            this.X264Tune = task.X264Tune;

            this.PreviewStartAt = task.PreviewStartAt;
            this.PreviewDuration = task.PreviewDuration;
        }
コード例 #25
0
        /// <summary>
        /// Generate a Query from an Encode Task Object.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <param name="enableFilters">
        /// The enableFilters.
        /// </param>
        /// <param name="verbosity">
        /// The verbosity.
        /// </param>
        /// <param name="disableLibDvdNav">
        /// The disable Lib Dvd Nav.
        /// </param>
        /// <returns>
        /// The CLI query for the Tabbed section of the main window UI
        /// </returns>
        private static string GenerateTabbedComponentsQuery(EncodeTask task, bool enableFilters, int verbosity, bool disableLibDvdNav)
        {
            string query = string.Empty;

            // Output Settings
            query += OutputSettingsQuery(task);

            // Filters Panel
            if (enableFilters)
                query += FiltersQuery(task);

            // Picture Settings
            query += PictureSettingsQuery(task);

            // Video Settings
            query += VideoSettingsQuery(task);

            // Audio Settings
            query += AudioSettingsQuery(task);

            // Subtitles Panel
            query += SubtitlesQuery(task);

            // Chapter Markers
            query += ChapterMarkersQuery(task);

            // Advanced Panel
            query += AdvancedQuery(task);

            // Extra Settings
            query += ExtraSettings(verbosity, disableLibDvdNav);

            return query;
        }
コード例 #26
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;
            if (preset == null || preset.Task == null)
            {
                return;
            }

            this.SelectedVideoEncoder = preset.Task.VideoEncoder;
            this.SelectedFramerate = preset.Task.Framerate.HasValue ? preset.Task.Framerate.Value.ToString(CultureInfo.InvariantCulture) : SameAsSource;

            this.IsConstantQuantity = preset.Task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality;

            switch (preset.Task.FramerateMode)
            {
                case FramerateMode.CFR:
                    this.IsConstantFramerate = true;
                    break;
                case FramerateMode.VFR:
                    this.IsVariableFramerate = true;
                    this.ShowPeakFramerate = false;
                    break;
                case FramerateMode.PFR:
                    this.IsPeakFramerate = true;
                    this.ShowPeakFramerate = true;
                    break;
            }

            double cqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);
            double rfValue = 0;
            this.SetQualitySliderBounds();
            switch (this.SelectedVideoEncoder)
            {
                case VideoEncoder.FFMpeg:
                case VideoEncoder.FFMpeg2:
                    if (preset.Task.Quality.HasValue)
                    {
                        int cq;
                        int.TryParse(preset.Task.Quality.Value.ToString(CultureInfo.InvariantCulture), out cq);
                        this.RF = 32 - cq;
                    }
                    break;
                case VideoEncoder.X264:

                    double multiplier = 1.0 / cqStep;
                    if (preset.Task.Quality.HasValue)
                    {
                        rfValue = preset.Task.Quality.Value * multiplier;
                    }

                    this.RF = this.QualityMax - (int)Math.Round(rfValue, 0);

                    break;

                case VideoEncoder.Theora:
                    if (preset.Task.Quality.HasValue)
                    {
                        this.RF = (int)preset.Task.Quality.Value;
                    }
                    break;
            }

            this.Task.TwoPass = preset.Task.TwoPass;
            this.Task.TurboFirstPass = preset.Task.TurboFirstPass;
            this.Task.VideoBitrate = preset.Task.VideoBitrate;

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

            if (preset.Task != null)
            {
                this.SetEncoder(preset.Task.VideoEncoder);
                this.X264PresetValue = preset.Task.VideoEncoder == VideoEncoder.X264
                                           ? (int)preset.Task.X264Preset
                                           : (int)x264Preset.Medium;
                this.H264Profile = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Profile : x264Profile.None;
                this.X264Tune = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.X264Tune : x264Tune.None;
                this.H264Level = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Level : "Auto";
                this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode;
                this.ExtraArguments = preset.Task.ExtraAdvancedArguments;

                this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;
            }
        }
コード例 #27
0
        /// <summary>
        /// Generate the Command Line Arguments for the Picture Settings tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string PictureSettingsQuery(EncodeTask task)
        {
            string query = string.Empty;

            if (task.Anamorphic != Anamorphic.Strict)
            {
                //if (task.MaxWidth.HasValue) query += string.Format(" -X {0}", task.MaxWidth);
                if (task.Width.HasValue && task.Width != 0) query += string.Format(" -w {0}", task.Width);

                //if (task.MaxHeight.HasValue) query += string.Format(" -Y {0}", task.MaxHeight);
                if (task.Height.HasValue && task.Height != 0) query += string.Format(" -l {0}", task.Height);
            }

            if (task.HasCropping)
            {
                query += string.Format(" --crop {0}:{1}:{2}:{3}", task.Cropping.Top, task.Cropping.Bottom, task.Cropping.Left, task.Cropping.Right);
            }

            switch (task.Anamorphic)
            {
                case Anamorphic.Strict:
                    query += " --strict-anamorphic ";
                    break;
                case Anamorphic.Loose:
                    query += " --loose-anamorphic ";
                    break;
                case Anamorphic.Custom:
                    query += " --custom-anamorphic ";

                    if (task.DisplayWidth.HasValue)
                        query += " --display-width " + task.DisplayWidth + " ";

                    if (task.KeepDisplayAspect)
                        query += " --keep-display-aspect ";

                    if (!task.KeepDisplayAspect)
                        query += string.Format(" --pixel-aspect {0}:{1}", task.PixelAspectX, task.PixelAspectY);
                    break;
            }

            if (task.Modulus.HasValue)
            {
                query += " --modulus " + task.Modulus;
            }

            return query;
        }
コード例 #28
0
        /// <summary>
        /// Generate the Command Line Arguments for the Video Settings Tab
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string VideoSettingsQuery(EncodeTask task)
        {
            string query = string.Empty;

            switch (task.VideoEncoder)
            {
                case VideoEncoder.FFMpeg:
                    query += " -e ffmpeg4";
                    break;
                case VideoEncoder.FFMpeg2:
                    query += " -e ffmpeg2";
                    break;
                case VideoEncoder.X264:
                    query += " -e x264";
                    break;
                case VideoEncoder.Theora:
                    query += " -e theora";
                    break;
                default:
                    query += " -e x264";
                    break;
            }

            switch (task.VideoEncodeRateType)
            {
                case VideoEncodeRateType.AverageBitrate:
                    if (task.VideoBitrate.HasValue)
                        query += string.Format(" -b {0}", task.VideoBitrate.Value);
                    break;
                case VideoEncodeRateType.ConstantQuality:
                    double value;
                    switch (task.VideoEncoder)
                    {
                        case VideoEncoder.FFMpeg:
                        case VideoEncoder.FFMpeg2:
                            query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
                            break;
                        case VideoEncoder.X264:
                            query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
                            break;
                        case VideoEncoder.Theora:
                            query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
                            break;
                    }
                    break;
            }

            if (task.TwoPass)
                query += " -2 ";

            if (task.TurboFirstPass)
                query += " -T ";

            if (task.Framerate.HasValue)
                query += string.Format(" -r {0}", task.Framerate.Value.ToString(CultureInfo.InvariantCulture));

            switch (task.FramerateMode)
            {
                case FramerateMode.CFR:
                    query += " --cfr";
                    break;
                case FramerateMode.VFR:
                    query += " --vfr";
                    break;
                case FramerateMode.PFR:
                    query += " --pfr";
                    break;
                default:
                    query += " --vfr";
                    break;
            }

            return query;
        }
コード例 #29
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.IsConstantFramerate);
            this.NotifyOfPropertyChange(() => this.IsConstantQuantity);
            this.NotifyOfPropertyChange(() => this.IsPeakFramerate);
            this.NotifyOfPropertyChange(() => this.IsVariableFramerate);
            this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder);
            this.NotifyOfPropertyChange(() => this.SelectedFramerate);
            this.NotifyOfPropertyChange(() => this.RF);
            this.NotifyOfPropertyChange(() => this.DisplayRF);
            this.NotifyOfPropertyChange(() => this.Task.VideoBitrate);
            this.NotifyOfPropertyChange(() => this.Task.TwoPass);
            this.NotifyOfPropertyChange(() => this.Task.TurboFirstPass);

            this.NotifyOfPropertyChange(() => this.X264Tune);
            this.NotifyOfPropertyChange(() => this.X264Preset);
            this.NotifyOfPropertyChange(() => this.H264Level);
            this.NotifyOfPropertyChange(() => this.H264Profile);
            this.NotifyOfPropertyChange(() => this.FastDecode);
            this.NotifyOfPropertyChange(() => this.ExtraArguments);
        }
コード例 #30
0
ファイル: EncodeTask.cs プロジェクト: pombredanne/hb-saintdev
        /// <summary>
        /// Initializes a new instance of the <see cref="EncodeTask"/> class.
        /// Copy Constructor
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        public EncodeTask(EncodeTask task)
        {
            this.AdvancedEncoderOptions = task.AdvancedEncoderOptions;
            this.AllowedPassthruOptions = new AllowedPassthru(task.AllowedPassthruOptions);
            this.Anamorphic             = task.Anamorphic;
            this.Angle = task.Angle;

            this.AudioTracks = new ObservableCollection <AudioTrack>();
            foreach (AudioTrack track in task.AudioTracks)
            {
                this.AudioTracks.Add(new AudioTrack(track));
            }

            this.ChapterNames = new ObservableCollection <ChapterMarker>();
            foreach (ChapterMarker track in task.ChapterNames)
            {
                this.ChapterNames.Add(new ChapterMarker(track));
            }

            this.ChapterMarkersFilePath = task.ChapterMarkersFilePath;
            this.Cropping              = new Cropping(task.Cropping);
            this.CustomDecomb          = task.CustomDecomb;
            this.CustomDeinterlace     = task.CustomDeinterlace;
            this.CustomDenoise         = task.CustomDenoise;
            this.CustomDetelecine      = task.CustomDetelecine;
            this.Deblock               = task.Deblock;
            this.Decomb                = task.Decomb;
            this.Deinterlace           = task.Deinterlace;
            this.Denoise               = task.Denoise;
            this.Destination           = task.Destination;
            this.Detelecine            = task.Detelecine;
            this.DisplayWidth          = task.DisplayWidth;
            this.EndPoint              = task.EndPoint;
            this.Framerate             = task.Framerate;
            this.FramerateMode         = task.FramerateMode;
            this.Grayscale             = task.Grayscale;
            this.HasCropping           = task.HasCropping;
            this.Height                = task.Height;
            this.IncludeChapterMarkers = task.IncludeChapterMarkers;
            this.IPod5GSupport         = task.IPod5GSupport;
            this.KeepDisplayAspect     = task.KeepDisplayAspect;
            this.MaxHeight             = task.MaxHeight;
            this.MaxWidth              = task.MaxWidth;
            this.Modulus               = task.Modulus;
            this.OptimizeMP4           = task.OptimizeMP4;
            this.OutputFormat          = task.OutputFormat;
            this.PixelAspectX          = task.PixelAspectX;
            this.PixelAspectY          = task.PixelAspectY;
            this.PointToPointMode      = task.PointToPointMode;
            this.Quality               = task.Quality;
            this.Source                = task.Source;
            this.StartPoint            = task.StartPoint;

            this.SubtitleTracks = new ObservableCollection <SubtitleTrack>();
            foreach (SubtitleTrack subtitleTrack in task.SubtitleTracks)
            {
                this.SubtitleTracks.Add(new SubtitleTrack(subtitleTrack));
            }

            this.Title                  = task.Title;
            this.TurboFirstPass         = task.TurboFirstPass;
            this.TwoPass                = task.TwoPass;
            this.VideoBitrate           = task.VideoBitrate;
            this.VideoEncoder           = task.VideoEncoder;
            this.VideoEncodeRateType    = task.VideoEncodeRateType;
            this.Width                  = task.Width;
            this.X264Preset             = task.X264Preset;
            this.QsvPreset              = task.QsvPreset;
            this.H264Profile            = task.H264Profile;
            this.X264Tune               = task.X264Tune;
            this.H264Level              = task.H264Level;
            this.FastDecode             = task.FastDecode;
            this.ExtraAdvancedArguments = task.ExtraAdvancedArguments;

            this.PreviewStartAt  = task.PreviewStartAt;
            this.PreviewDuration = task.PreviewDuration;

            this.ShowAdvancedTab = task.ShowAdvancedTab;

            this.X265Preset  = task.X265Preset;
            this.X265Tune    = task.X265Tune;
            this.H265Profile = task.H265Profile;
        }
コード例 #31
0
        /// <summary>
        /// Generate the Command Line Arguments for the Advanced Encoder Options
        /// </summary>
        /// <param name="task">
        /// The encode task.
        /// </param>
        /// <returns>
        /// A Cli Query as a string
        /// </returns>
        private static string AdvancedQuery(EncodeTask task)
        {
            if (task.VideoEncoder == VideoEncoder.X264)
            {
                string query = string.Empty;

                if (task.x264Preset != x264Preset.None)
                {
                    query += string.Format("--x264-preset={0} ", task.x264Preset.ToString().ToLower().Replace(" ", string.Empty));
                }

                if (task.x264Profile != x264Profile.None)
                {
                    query += string.Format("--x264-profile={0} ", task.x264Profile.ToString().ToLower().Replace(" ", string.Empty));
                }

                if (task.X264Tune != x264Tune.None)
                {
                    query += string.Format("--x264-tune={0} ", task.X264Tune.ToString().ToLower().Replace(" ", string.Empty));
                }

                if (!string.IsNullOrEmpty(task.AdvancedEncoderOptions))
                {
                    query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
                }

                return query;
            }

            return string.IsNullOrEmpty(task.AdvancedEncoderOptions) ? string.Empty : string.Format(" -x {0}", task.AdvancedEncoderOptions);
        }
コード例 #32
0
ファイル: AudioViewModel.cs プロジェクト: seven1240/HandBrake
        /// <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;

            if (preset != null && preset.Task != null)
            {
                this.AddTracksFromPreset(preset);
                this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions);
            }
            this.NotifyOfPropertyChange(() => this.Task);

            this.Task.AllowedPassthruOptions.IsEnabled =
                 this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);
        }