Exemplo n.º 1
0
        private static string ChapterMarkersQuery(BatchTitle batchTitle, frmMain mainWindow)
        {
            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(batchTitle.OutputDestination);
            string sourceTitle = batchTitle.TitleNumber.ToString();

            if (mainWindow.Check_ChapterMarkers.Checked && mainWindow.Check_ChapterMarkers.Enabled)
            {
                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(batchTitle.Title, path) == false)
                    {
                        query += " -m ";
                    }
                    else
                    {
                        query += " --markers=" + "\"" + path + "\"";
                    }
                }
                else
                {
                    query += " -m";
                }
            }

            return(query);
        }
Exemplo n.º 2
0
        public static QueueTask GenerateFullQueryForBatchTitle(frmMain mainWindow, BatchTitle batchTitle)
        {
            int?angle = null;

            if (mainWindow.drop_angle.SelectedItem != null)
            {
                string selectedAngleStr = mainWindow.drop_angle.SelectedItem.ToString();

                int tempAngle;
                if (int.TryParse(selectedAngleStr, out tempAngle))
                {
                    angle = tempAngle;
                }
            }

            string sourcePath = mainWindow.sourcePath;

            // Create the CLI Query
            string query = string.Empty;

            query += SourceQuery(sourcePath, batchTitle, angle);
            query += DestinationQuery(batchTitle);
            query += GenerateTabbedComponentsQuery(batchTitle, mainWindow, true, QueryPictureSettingsMode.UserInterfaceSettings, 0, 0);

            // Create the Queue Task and setup the EncodeTask model object.


            Preset preset = null;

            if (mainWindow.treeView_presets.SelectedNode != null)
            {
                preset = mainWindow.treeView_presets.SelectedNode.Tag as Preset;
            }

            bool isCustom = true;

            if (preset != null && preset.IsBuildIn)
            {
                isCustom = false;
            }

            EncodeTask task = CreateEncodeTaskObjectFromBatch(batchTitle, mainWindow);

            QueueTask queueTask = new QueueTask(query)
            {
                Source      = task.Source,
                Destination = task.Destination,
                Title       = mainWindow.GetTitle(),
                CustomQuery = (mainWindow.rtf_query.Text != string.Empty) || isCustom,
                Task        = task,
                Query       = query,
            };

            return(queueTask);
        }
Exemplo n.º 3
0
        private static string SourceQuery(string sourcePath, BatchTitle batchTitle, int?angle)
        {
            string query = string.Empty;

            if (sourcePath.EndsWith("\\"))
            {
                query = " -i " + sourcePath;
            }
            else
            {
                query = " -i " + '"' + sourcePath + '"';
            }

            query += " -t " + batchTitle.TitleNumber;

            if (!UserSettingService.GetUserSetting <bool>(ASUserSettingConstants.DisableLibDvdNav) && angle.HasValue)
            {
                query += " --angle " + angle;
            }

            query += string.Format(" -c {0}-{1}", batchTitle.Title.Chapters.Min(c => c.ChapterNumber), batchTitle.Title.Chapters.Max(c => c.ChapterNumber));
            return(query);
        }
Exemplo n.º 4
0
        private static string GenerateTabbedComponentsQuery(BatchTitle batchTitle, frmMain mainWindow, bool filters, QueryPictureSettingsMode mode, int width, int height)
        {
            string query = string.Empty;

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

            // Filters Panel
            if (filters)
            {
                query += FiltersQuery(mainWindow);
            }

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

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

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

            // Subtitles Panel
            query += mainWindow.Subtitles.GetCliQuery;

            // Chapter Markers
            query += ChapterMarkersQuery(batchTitle, mainWindow);

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

            // Extra Settings
            query += ExtraSettings();

            return(query);
        }
Exemplo n.º 5
0
        private static string DestinationQuery(BatchTitle batchTitle)
        {
            string query = string.Format(" -o \"{0}\" ", batchTitle.OutputDestination);

            return(query);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create the EncodeTask model from the currently selected control options.
        /// </summary>
        /// <param name="frmMain">
        /// The frm main.
        /// </param>
        /// <returns>
        /// An EncodeTask Object
        /// </returns>
        private static EncodeTask CreateEncodeTaskObjectFromBatch(BatchTitle batchTitle, frmMain frmMain)
        {
            EncodeTask task = new EncodeTask();

            // Source, Destination and Output Settings
            task.Destination = batchTitle.OutputDestination;

            string sourcePath = frmMain.selectedTitle != null && File.Exists(frmMain.selectedTitle.SourceName) ? frmMain.selectedTitle.SourceName.Trim() : frmMain.sourcePath;

            if (!string.IsNullOrEmpty(sourcePath) && sourcePath.Trim() != "Select \"Source\" to continue")
            {
                task.Source = sourcePath;
            }

            task.Title = batchTitle.TitleNumber;

            task.StartPoint = batchTitle.Title.Chapters.First().ChapterNumber;
            task.EndPoint   = batchTitle.Title.Chapters.Last().ChapterNumber;

            int angle;

            int.TryParse(frmMain.drop_angle.Text, out angle);

            task.Angle = angle;

            switch (frmMain.drop_mode.SelectedIndex)
            {
            case 0:     // Chapters
                task.PointToPointMode = PointToPointMode.Chapters;
                break;

            case 1:     // Seconds
                task.PointToPointMode = PointToPointMode.Seconds;
                break;

            case 2:     // Frames
                task.PointToPointMode = PointToPointMode.Frames;
                break;

            default:
                break;
            }

            task.OutputFormat = EnumHelper <OutputFormat> .GetValue(frmMain.drop_format.Text.Replace(" File", string.Empty).Trim());

            task.LargeFile     = frmMain.check_largeFile.Checked;
            task.IPod5GSupport = frmMain.check_largeFile.Checked;
            task.OptimizeMP4   = frmMain.check_optimiseMP4.Checked;

            // Picture Settings
            int width, height;

            int.TryParse(frmMain.PictureSettings.crop_top.Text, out width);
            int.TryParse(frmMain.PictureSettings.crop_top.Text, out height);
            task.Width  = width;
            task.Height = height;
            int top, bottom, left, right;

            int.TryParse(frmMain.PictureSettings.crop_top.Text, out top);
            int.TryParse(frmMain.PictureSettings.crop_top.Text, out bottom);
            int.TryParse(frmMain.PictureSettings.crop_top.Text, out left);
            int.TryParse(frmMain.PictureSettings.crop_top.Text, out right);
            task.Cropping = new Cropping(top, bottom, left, right);

            int modulus, displayWidth, parX, parY;

            int.TryParse(frmMain.PictureSettings.drp_modulus.SelectedItem.ToString(), out modulus);
            int.TryParse(frmMain.PictureSettings.updownDisplayWidth.Text, out displayWidth);
            int.TryParse(frmMain.PictureSettings.updownParWidth.Text, out parX);
            int.TryParse(frmMain.PictureSettings.updownParHeight.Text, out parY);
            switch (frmMain.PictureSettings.drp_anamorphic.SelectedIndex)
            {
            case 0:
                task.Anamorphic = Anamorphic.None;
                task.Modulus    = modulus;
                break;

            case 1:
                task.Anamorphic = Anamorphic.Strict;
                break;

            case 2:
                task.Anamorphic = Anamorphic.Loose;
                task.Modulus    = modulus;
                break;

            case 3:
                task.Anamorphic        = Anamorphic.Custom;
                task.Modulus           = modulus;
                task.DisplayWidth      = displayWidth;
                task.KeepDisplayAspect = frmMain.PictureSettings.check_KeepAR.Checked;
                task.PixelAspectX      = parX;
                task.PixelAspectY      = parY;
                break;
            }

            // Filter Settings
            task.Deblock           = frmMain.Filters.Deblock;
            task.Decomb            = frmMain.Filters.Decomb;
            task.CustomDecomb      = frmMain.Filters.CustomDecombValue;
            task.Deinterlace       = frmMain.Filters.Deinterlace;
            task.CustomDeinterlace = frmMain.Filters.CustomDeInterlaceValue;
            task.Deblock           = frmMain.Filters.Deblock;
            task.Denoise           = frmMain.Filters.Denoise;
            task.CustomDenoise     = frmMain.Filters.CustomDenoiseValue;
            task.Detelecine        = frmMain.Filters.Detelecine;
            task.CustomDetelecine  = frmMain.Filters.CustomDeTelecineValue;
            task.Grayscale         = frmMain.Filters.GrayScale;

            // Video Settings
            task.VideoEncoder = EnumHelper <VideoEncoder> .GetValue(frmMain.drp_videoEncoder.Text);

            int videoBitrate;

            int.TryParse(frmMain.text_bitrate.Text, out videoBitrate);
            task.VideoBitrate        = videoBitrate;
            task.VideoEncodeRateType = frmMain.radio_cq.Checked
                                           ? VideoEncodeRateType.ConstantQuality
                                           : VideoEncodeRateType.AverageBitrate;
            task.TwoPass        = frmMain.check_2PassEncode.Checked;
            task.TurboFirstPass = frmMain.check_turbo.Checked;
            double framerate;

            double.TryParse(frmMain.drp_videoFramerate.Text, out framerate);
            task.Framerate     = framerate;
            task.FramerateMode = frmMain.drp_videoFramerate.SelectedIndex == 0
                                     ? (frmMain.radio_constantFramerate.Checked ? FramerateMode.CFR : FramerateMode.VFR)
                                     : (frmMain.radio_constantFramerate.Checked ? FramerateMode.CFR : FramerateMode.PFR);

            if (frmMain.radio_cq.Checked)
            {
                double cqStep = UserSettingService.GetUserSetting <double>(ASUserSettingConstants.X264Step);
                switch (frmMain.drp_videoEncoder.Text)
                {
                case "MPEG-4 (FFmpeg)":
                case "MPEG-2 (FFmpeg)":
                    task.Quality = 31 - (frmMain.slider_videoQuality.Value - 1);
                    break;

                case "H.264 (x264)":
                    double value = 51 - (frmMain.slider_videoQuality.Value * cqStep);
                    task.Quality = Math.Round(value, 2);
                    break;

                case "VP3 (Theora)":
                    task.Quality = frmMain.slider_videoQuality.Value;
                    break;
                }
            }

            // Audio
            task.AudioTracks = new ObservableCollection <AudioTrack>(frmMain.AudioSettings.AudioTracks);

            // Subtitles
            task.SubtitleTracks = new ObservableCollection <SubtitleTrack>(frmMain.Subtitles.SubtitlesList);

            // Chapters
            task.IncludeChapterMarkers = frmMain.Check_ChapterMarkers.Checked;

            //skim the chapters from the title
            task.ChapterNames = new ObservableCollection <ChapterMarker>();
            foreach (var chapter in batchTitle.Title.Chapters)
            {
                task.ChapterNames.Add(new ChapterMarker(chapter.ChapterNumber, chapter.ChapterName));
            }

            // Advanced Options
            task.AdvancedEncoderOptions = X264Query(frmMain).Replace("-x", string.Empty).Trim();

            // Extra Settings
            task.Verbosity        = UserSettingService.GetUserSetting <int>(ASUserSettingConstants.Verbosity);
            task.DisableLibDvdNav = UserSettingService.GetUserSetting <bool>(ASUserSettingConstants.DisableLibDvdNav);

            return(task);
        }