Beispiel #1
0
        /// <summary>
        /// Checks if the source file if from a DVD/Blu-ray stucture & asks for title list if needed
        /// </summary>
        /// <param name="fileName">input file name</param>
        /// <param name="iFileTemp">reference to the mediainfofile object</param>
        /// <returns>true if DVD/Blu-ray source is found, false if no DVD/Blu-ray source is available</returns>
        private bool GetDVDorBluraySource(string fileName, ref MediaInfoFile iFileTemp)
        {
            iFileTemp = null;
            using (frmStreamSelect frm = new frmStreamSelect(fileName, SelectionMode.One))
            {
                // check if playlists have been found
                if (frm.TitleCount == 0)
                {
                    return(false);
                }

                // only continue if a DVD or Blu-ray structure is found
                if (!frm.IsDVDOrBluraySource)
                {
                    return(false);
                }

                // open the selection window
                DialogResult dr = DialogResult.OK;
                dr = frm.ShowDialog();

                if (dr != DialogResult.OK)
                {
                    return(false);
                }

                ChapterInfo oChapterInfo  = frm.SelectedSingleChapterInfo;
                string      strSourceFile = string.Empty;
                if (frm.IsDVDSource)
                {
                    strSourceFile = Path.Combine(Path.GetDirectoryName(oChapterInfo.SourceFilePath), oChapterInfo.Title + "_0.IFO");
                }
                else
                {
                    strSourceFile = oChapterInfo.SourceFilePath;
                }
                if (!File.Exists(strSourceFile))
                {
                    _oLog.LogEvent(strSourceFile + " cannot be found. skipping...");
                    return(true);
                }
                iFileTemp = new MediaInfoFile(strSourceFile, ref _oLog, oChapterInfo.PGCNumber, oChapterInfo.AngleNumber);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Checks if the source file if from a DVD stucture & asks for title list if needed
        /// </summary>
        /// <param name="fileName">input file name</param>
        /// <returns>true if DVD source is found, false if no DVD source is available</returns>
        private bool GetDVDSource(ref string fileName)
        {
            iPGC   = 1;
            iAngle = 0;
            using (frmStreamSelect frm = new frmStreamSelect(fileName, SelectionMode.One))
            {
                // check if playlists have been found
                if (frm.TitleCount == 0)
                {
                    return(false);
                }

                // only continue if a DVD or Blu-ray structure is found
                if (!frm.IsDVDSource)
                {
                    return(false);
                }

                // open the selection window if not exactly one title set with the desired minimum length is found
                DialogResult dr = DialogResult.OK;
                if (frm.TitleCountWithRequiredLength != 1)
                {
                    dr = frm.ShowDialog();
                }

                if (dr != DialogResult.OK)
                {
                    return(false);
                }

                ChapterInfo oChapterInfo  = frm.SelectedSingleChapterInfo;
                string      strSourceFile = Path.Combine(Path.GetDirectoryName(oChapterInfo.SourceFilePath), oChapterInfo.Title + "_0.IFO");
                if (!File.Exists(strSourceFile))
                {
                    // cannot be found. skipping...;
                    return(false);
                }
                iPGC     = oChapterInfo.PGCNumber;
                iAngle   = oChapterInfo.AngleNumber;
                fileName = strSourceFile;
            }
            return(true);
        }
Beispiel #3
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO Files (*.ifo)|*.ifo|MPLS Files (*.mpls)|*.mpls|Text Files (*.txt)|*.txt|All Files supported (*.ifo,*.mpls,*.txt)|*.ifo;*.mpls;*.txt";
                openFileDialog.FilterIndex = 4;

                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new DvdExtractor();
                        using (frmStreamSelect frm = new frmStreamSelect(ex))
                        {
                            if (ex is DvdExtractor)
                            {
                                frm.Text = "Select your PGC";
                            }
                            else
                            {
                                frm.Text = "Select your Playlist";
                            }
                            ex.GetStreams(input.Text);
                            if (frm.ChapterCount == 1 || frm.ShowDialog(this) == DialogResult.OK)
                            {
                                pgc = frm.SelectedSingleChapterInfo;
                                if (pgc.FramesPerSecond == 0)
                                {
                                    pgc.FramesPerSecond = 25.0;
                                }
                                if (String.IsNullOrEmpty(pgc.LangCode))
                                {
                                    pgc.LangCode = "und";
                                }
                            }
                        }
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD, BluRay disc, or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                                Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                                new DvdExtractor() as ChapterExtractor :
                                File.Exists(Path.Combine(input.Text, "VIDEO_TS.IFO")) ?
                                new DvdExtractor() as ChapterExtractor :
                                Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                                new BlurayExtractor() as ChapterExtractor :
                                null;

                            if (ex == null)
                            {
                                throw new Exception("The location was not detected as DVD, or Blu-Ray.");
                            }

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                {
                                    frm.Text = "Select your Title";
                                }
                                else
                                {
                                    frm.Text = "Select your Playlist";
                                }
                                ex.GetStreams(input.Text);
                                if (frm.ChapterCount == 1 || frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    pgc = frm.SelectedSingleChapterInfo;
                                    if (pgc.FramesPerSecond == 0)
                                    {
                                        pgc.FramesPerSecond = 25.0;
                                    }
                                    if (String.IsNullOrEmpty(pgc.LangCode))
                                    {
                                        pgc.LangCode = "und";
                                    }
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }
        }
Beispiel #4
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO files (*.ifo)|*.ifo|Container files (*.mkv,*.mp4)|*.mkv;*.mp4|MPLS files (*.mpls)|*.mpls|Chapter files (*.txt,*.xml)|*.txt;*.xml|All supported files (*.ifo,*.mkv,*.mp4,*.mpls,*.txt,*.xml)|*.ifo;*.mkv;*.mp4;*.mpls;*.txt;*.xml";
                openFileDialog.FilterIndex = 5;

                if (this.openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                input.Text = openFileDialog.FileName;
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD/BluRay disc or folder";
                    if (d.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    input.Text = d.SelectedPath;
                }
            }

            using (frmStreamSelect frm = new frmStreamSelect(input.Text))
            {
                if (frm.TitleCount == 0)
                {
                    MessageBox.Show("No chapters found");
                    return;
                }

                DialogResult dr = DialogResult.OK;
                if (frm.TitleCountWithRequiredLength != 1)
                {
                    dr = frm.ShowDialog();
                }

                if (dr != DialogResult.OK)
                {
                    return;
                }

                pgc = frm.SelectedSingleChapterInfo;
            }

            bNoUpdates = true;
            if (pgc.FramesPerSecond > 0)
            {
                fpsChooserIn.Value = (decimal)pgc.FramesPerSecond;
                bInputFPSKnown     = true;
                if (fpsChooserOut.Value == null)
                {
                    fpsChooserOut.Value = (decimal)pgc.FramesPerSecond;
                }
            }
            else
            {
                fpsChooserIn.Value  = null;
                bInputFPSKnown      = false;
                pgc.FramesPerSecond = 0;
            }
            bNoUpdates = false;

            ResetChapterView(-1);

            chaptersGroupbox.Text = " Chapters ";
            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }

            string fileName = Path.GetFileNameWithoutExtension(input.Text);

            if (this.pgc.PGCNumber > 0)
            {
                chaptersGroupbox.Text += "- VTS " + pgc.TitleNumber.ToString("D2") + " - PGC " + pgc.PGCNumber.ToString("D2") + " ";
                if (FileUtil.RegExMatch(fileName, @"_\d{1,2}\z", false))
                {
                    // file ends with e.g. _1 as in VTS_01_1
                    fileName  = fileName.Substring(0, fileName.LastIndexOf('_'));
                    fileName += "_" + this.pgc.PGCNumber;
                }
            }

            fileName = FileUtil.GetOutputFilePrefix(input.Text) + fileName + " - Chapter Information.txt";
            if (rbXML.Checked)
            {
                fileName = Path.ChangeExtension(fileName, "xml");
            }
            else if (rbQPF.Checked)
            {
                fileName = Path.ChangeExtension(fileName, "qpf");
            }

            output.Text = Path.Combine(FileUtil.GetOutputFolder(input.Text), fileName);
        }
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter = "IFO Files (*.ifo)|*.ifo|MPLS Files (*.mpls)|*.mpls|Text Files (*.txt)|*.txt|All Files supported (*.ifo,*.mpls,*.txt)|*.ifo;*.mpls;*.txt";
                openFileDialog.FilterIndex = 4;

               if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLower().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new IfoExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLower().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description = "Select DVD, BluRay disc, or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                              Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                              new DvdExtractor() as ChapterExtractor :
                              Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                              new BlurayExtractor() as ChapterExtractor :
                              null;

                            if (ex == null)
                                throw new Exception("The location was not detected as DVD, or Blu-Ray.");

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                    frm.Text = "Select your PGC";
                                else
                                    frm.Text = "Select your Playlist";
                                ex.GetStreams(input.Text);
                                if (frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    pgc = frm.ProgramChain;
                                    if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = 25.0;
                                    if (pgc.LangCode == null) pgc.LangCode = "und";
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
                chapterListView.Items[0].Selected = true;
        }
Beispiel #6
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO files (*.ifo)|*.ifo|MKV files (*.mkv)|*.mkv|MPLS files (*.mpls)|*.mpls|Text files (*.txt)|*.txt|All supported files (*.ifo,*.mkv,*.mpls,*.txt)|*.ifo;*.mkv;*.mpls;*.txt";
                openFileDialog.FilterIndex = 5;

                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLowerInvariant().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new DvdExtractor();
                        using (frmStreamSelect frm = new frmStreamSelect(ex))
                        {
                            if (ex is DvdExtractor)
                            {
                                frm.Text = "Select your PGC";
                            }
                            else
                            {
                                frm.Text = "Select your Playlist";
                            }
                            ex.GetStreams(input.Text);
                            if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                            {
                                if (frm.ChapterCount == 0)
                                {
                                    if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                    {
                                        MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                    }
                                    else
                                    {
                                        MessageBox.Show("No titles found.");
                                    }
                                    return;
                                }
                                else
                                {
                                    pgc = frm.SelectedSingleChapterInfo;
                                    if (pgc.FramesPerSecond == 0)
                                    {
                                        MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                        pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                    }
                                    if (String.IsNullOrEmpty(pgc.LangCode))
                                    {
                                        pgc.LangCode = "und";
                                    }
                                }
                            }
                        }
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("txt"))
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mkv"))
                    {
                        ChapterExtractor ex = new MkvExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        MessageBox.Show("The input file is not supported.");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD, BluRay disc or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                                Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                                new DvdExtractor() as ChapterExtractor :
                                File.Exists(Path.Combine(input.Text, "VIDEO_TS.IFO")) ?
                                new DvdExtractor() as ChapterExtractor :
                                Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                                new BlurayExtractor() as ChapterExtractor :
                                null;

                            if (ex == null)
                            {
                                MessageBox.Show("The input folder is not supported.");
                                return;
                            }

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                {
                                    frm.Text = "Select your Title";
                                }
                                else
                                {
                                    frm.Text = "Select your Playlist";
                                }
                                ex.GetStreams(input.Text);
                                if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    if (frm.ChapterCount == 0)
                                    {
                                        if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                        {
                                            MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                        }
                                        else
                                        {
                                            MessageBox.Show("No titles found.");
                                        }
                                        return;
                                    }
                                    else
                                    {
                                        pgc = frm.SelectedSingleChapterInfo;
                                        if (pgc.FramesPerSecond == 0)
                                        {
                                            MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                            pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                        }
                                        if (String.IsNullOrEmpty(pgc.LangCode))
                                        {
                                            pgc.LangCode = "und";
                                        }
                                    }
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }

            if (pgc.FramesPerSecond > 0)
            {
                fpsChooser.Value = (decimal)pgc.FramesPerSecond;
                bFPSKnown        = true;
            }
            else
            {
                bFPSKnown = false;
            }

            string path = String.Empty;

            if (Directory.Exists(MainForm.Instance.Settings.DefaultOutputDir) && FileUtil.IsDirWriteable(MainForm.Instance.Settings.DefaultOutputDir))
            {
                path = MainForm.Instance.Settings.DefaultOutputDir;
            }
            else if (!String.IsNullOrEmpty(input.Text) && Directory.Exists(Path.GetDirectoryName(input.Text)) && FileUtil.IsDirWriteable(Path.GetDirectoryName(input.Text)))
            {
                path = Path.GetDirectoryName(input.Text);
            }

            string file = String.Empty;

            if (String.IsNullOrEmpty(Path.GetFileNameWithoutExtension(input.Text)))
            {
                file = "Chapter Information.txt";
            }
            else
            {
                file = Path.GetFileNameWithoutExtension(input.Text) + " - Chapter Information.txt";
            }
            if (rbXML.Checked)
            {
                Path.ChangeExtension(file, "xml");
            }
            else if (rbQPF.Checked)
            {
                Path.ChangeExtension(file, "qpf");
            }

            if (String.IsNullOrEmpty(path))
            {
                output.Text = file;
            }
            else
            {
                output.Text = Path.Combine(path, file);
            }
        }