예제 #1
0
        /// <summary>
        /// creates a project
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void queueButton_Click(object sender, System.EventArgs e)
        {
            if (dialogMode)
            {
                return;
            }

            if (!configured)
            {
                MessageBox.Show("You must select the input and output file to continue",
                                "Configuration incomplete", MessageBoxButtons.OK);
                return;
            }

            if (!Drives.ableToWriteOnThisDrive(Path.GetPathRoot(output.Filename)))
            {
                MessageBox.Show("MeGUI cannot write on the disc " + Path.GetPathRoot(output.Filename) + "\n" +
                                "Please, select another output path to save your project...", "Configuration Incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            JobChain prepareJobs = null;
            string   videoInput  = input.Filename;

            // create pgcdemux job if needed
            if (Path.GetExtension(input.Filename).ToUpperInvariant().Equals(".IFO"))
            {
                if (iFile.VideoInfo.PGCCount > 1 || iFile.VideoInfo.AngleCount > 0)
                {
                    // pgcdemux must be used as either multiple PGCs or a multi-angle disc are found
                    string tempFile = Path.Combine(Path.GetDirectoryName(output.Filename), Path.GetFileNameWithoutExtension(output.Filename) + "_1.VOB");
                    prepareJobs = new SequentialChain(new PgcDemuxJob(videoInput, tempFile, iFile.VideoInfo.PGCNumber, iFile.VideoInfo.AngleNumber));
                    videoInput  = tempFile;

                    string filesToOverwrite = string.Empty;
                    for (int i = 1; i < 10; i++)
                    {
                        string file = Path.Combine(Path.GetDirectoryName(output.Filename), Path.GetFileNameWithoutExtension(output.Filename) + "_" + i + ".VOB");
                        if (File.Exists(file))
                        {
                            filesToOverwrite += file + "\n";
                        }
                    }
                    if (!String.IsNullOrEmpty(filesToOverwrite))
                    {
                        DialogResult dr = MessageBox.Show("The pgc demux files already exist: \n" + filesToOverwrite + "\n" +
                                                          "Do you want to overwrite these files?", "Configuration Incomplete",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dr == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    // change from _0.IFO to _1.VOB for the indexer
                    videoInput = input.Filename.Substring(0, input.Filename.Length - 5) + "1.VOB";
                    if (!File.Exists(videoInput))
                    {
                        MessageBox.Show("The file following file cannot be found: \n" + videoInput, "Configuration Incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            else if (Path.GetExtension(input.Filename).ToUpperInvariant().Equals(".MPLS") && IndexerUsed != IndexType.DGI && IndexerUsed != IndexType.DGM)
            {
                // blu-ray playlist without DGI/DGM used - therefore eac3to must be used first

                string strTempMKVFile = Path.Combine(Path.GetDirectoryName(output.Filename), Path.GetFileNameWithoutExtension(output.Filename) + ".mkv");
                if (File.Exists(strTempMKVFile))
                {
                    DialogResult dr = MessageBox.Show("The demux file already exist: \n" + strTempMKVFile + "\n" +
                                                      "Do you want to overwrite this file?", "Configuration Incomplete",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.No)
                    {
                        return;
                    }
                }

                StringBuilder sb = new StringBuilder();
                sb.Append(string.Format("{0}:\"{1}\" ", iFile.VideoInfo.Track.TrackID, strTempMKVFile));

                foreach (AudioTrackInfo oStreamControl in AudioTracks.CheckedItems)
                {
                    bool       bCoreOnly  = false;
                    AudioCodec audioCodec = oStreamControl.AudioCodec;
                    if (oStreamControl.HasCore && !MainForm.Instance.Settings.Eac3toDefaultToHD)
                    {
                        // audio file can be demuxed && should be touched (core needed)
                        if (audioCodec == AudioCodec.THDAC3)
                        {
                            oStreamControl.Codec      = "AC-3";
                            oStreamControl.AudioType  = AudioType.AC3;
                            oStreamControl.AudioCodec = AudioCodec.AC3;
                            bCoreOnly = true;
                            oStreamControl.HasCore = false;
                        }
                        else if (audioCodec == AudioCodec.DTS)
                        {
                            oStreamControl.Codec      = "DTS";
                            oStreamControl.AudioType  = AudioType.DTS;
                            oStreamControl.AudioCodec = AudioCodec.DTS;
                            oStreamControl.HasCore    = false;
                            bCoreOnly = true;
                        }
                    }

                    // core must be extracted (workaround for an eac3to issue)
                    // http://bugs.madshi.net/view.php?id=450
                    if (audioCodec == AudioCodec.EAC3)
                    {
                        bCoreOnly = true;
                    }

                    string strSourceFileName = Path.Combine(Path.GetDirectoryName(input.Filename), Path.GetFileNameWithoutExtension(strTempMKVFile));

                    oStreamControl.SourceFileName = strSourceFileName;

                    sb.Append(string.Format("{0}:\"{1}\" ", oStreamControl.TrackID, Path.Combine(Path.GetDirectoryName(output.Filename), oStreamControl.DemuxFileName)));
                    if (bCoreOnly)
                    {
                        sb.Append("-core ");
                    }
                }

                HDStreamsExJob oJob = new HDStreamsExJob(new List <string>()
                {
                    input.Filename
                }, Path.GetDirectoryName(output.Filename), null, sb.ToString(), 2);
                prepareJobs = new SequentialChain(oJob);
                videoInput  = strTempMKVFile;
            }

            switch (IndexerUsed)
            {
            case IndexType.D2V:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateD2VIndexJob(videoInput)));
                MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.DGI:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateDGNVIndexJob(videoInput)));
                MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.DGM:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateDGMIndexJob(videoInput)));
                MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.FFMS:
            {
                FFMSIndexJob job = generateFFMSIndexJob(videoInput);
                if (job.DemuxMode > 0 && job.AudioTracks.Count > 0 &&
                    (txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("MATROSKA") ||
                     txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("BLU-RAY PLAYLIST")))
                {
                    job.DemuxMode        = 0;
                    job.AudioTracksDemux = job.AudioTracks;
                    job.AudioTracks      = new List <AudioTrackInfo>();
                    if (txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("MATROSKA"))
                    {
                        MkvExtractJob extractJob = new MkvExtractJob(videoInput, Path.GetDirectoryName(this.output.Filename), job.AudioTracksDemux);
                        prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(extractJob));
                    }
                }
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(job));
                MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.LSMASH:
            {
                LSMASHIndexJob job = generateLSMASHIndexJob(videoInput);
                if (job.DemuxMode > 0 && job.AudioTracks.Count > 0 &&
                    (txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("MATROSKA") ||
                     txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("BLU-RAY PLAYLIST")))
                {
                    job.DemuxMode        = 0;
                    job.AudioTracksDemux = job.AudioTracks;
                    job.AudioTracks      = new List <AudioTrackInfo>();
                    if (txtContainerInformation.Text.Trim().ToUpperInvariant().Equals("MATROSKA"))
                    {
                        MkvExtractJob extractJob = new MkvExtractJob(videoInput, Path.GetDirectoryName(this.output.Filename), job.AudioTracksDemux);
                        prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(extractJob));
                    }
                }
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(job));
                MainForm.Instance.Jobs.AddJobsWithDependencies(prepareJobs, true);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }
            }
        }
예제 #2
0
        /// <summary>
        /// creates a project
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void queueButton_Click(object sender, System.EventArgs e)
        {
            if (dialogMode)
            {
                return;
            }

            if (!configured)
            {
                MessageBox.Show("You must select the input and output file to continue",
                                "Configuration incomplete", MessageBoxButtons.OK);
                return;
            }

            if (!Drives.ableToWriteOnThisDrive(Path.GetPathRoot(output.Text)))
            {
                MessageBox.Show("MeGUI cannot write on the disc " + Path.GetPathRoot(output.Text) + "\n" +
                                "Please, select another output path to save your project...", "Configuration Incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            JobChain prepareJobs = null;
            string   videoInput  = input.Filename;

            // create pgcdemux job if needed
            if (cbPGC.SelectedIndex > 0 &&
                Path.GetExtension(input.Filename.ToUpper(System.Globalization.CultureInfo.InvariantCulture)) == ".VOB")
            {
                string videoIFO;
                // PGC numbers are not present in VOB, so we check the main IFO
                if (Path.GetFileName(input.Filename).ToUpper(System.Globalization.CultureInfo.InvariantCulture).Substring(0, 4) == "VTS_")
                {
                    videoIFO = input.Filename.Substring(0, input.Filename.LastIndexOf("_")) + "_0.IFO";
                }
                else
                {
                    videoIFO = Path.ChangeExtension(input.Filename, ".IFO");
                }

                if (File.Exists(videoIFO))
                {
                    prepareJobs = new SequentialChain(new PgcDemuxJob(videoIFO, Path.GetDirectoryName(output.Text), cbPGC.SelectedIndex));
                    videoInput  = Path.Combine(Path.GetDirectoryName(output.Text), "VTS_01_1.VOB");
                    for (int i = 1; i < 10; i++)
                    {
                        string file = Path.Combine(Path.GetDirectoryName(output.Text), "VTS_01_" + i + ".VOB");
                        if (File.Exists(file))
                        {
                            MessageBox.Show("The pgc demux file already exists: \n" + file + "\n\n" +
                                            "Please select another output path to save your project.", "Configuration Incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                }
            }

            switch (IndexerUsed)
            {
            case IndexType.D2V:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateD2VIndexJob(videoInput)));
                mainForm.Jobs.addJobsWithDependencies(prepareJobs);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.DGI:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateDGNVIndexJob(videoInput)));
                mainForm.Jobs.addJobsWithDependencies(prepareJobs);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.DGA:
            {
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(generateDGAIndexJob(videoInput)));
                mainForm.Jobs.addJobsWithDependencies(prepareJobs);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }

            case IndexType.FFMS:
            {
                FFMSIndexJob job = generateFFMSIndexJob(videoInput);
                if (txtContainerInformation.Text.Trim().ToUpper(System.Globalization.CultureInfo.InvariantCulture).Equals("MATROSKA") &&
                    job.DemuxMode > 0 && job.AudioTracks.Count > 0)
                {
                    job.AudioTracksDemux = job.AudioTracks;
                    job.AudioTracks      = new List <AudioTrackInfo>();
                    MkvExtractJob extractJob = new MkvExtractJob(videoInput, Path.GetDirectoryName(this.output.Text), job.AudioTracksDemux);
                    prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(extractJob));
                }
                prepareJobs = new SequentialChain(prepareJobs, new SequentialChain(job));
                mainForm.Jobs.addJobsWithDependencies(prepareJobs);
                if (this.closeOnQueue.Checked)
                {
                    this.Close();
                }
                break;
            }
            }
        }