Пример #1
0
        public Eac3toInfo(List <string> input, MediaInfoFile iFile, LogItem oLog)
        {
            // create log instance
            if (oLog == null)
            {
                _log = MainForm.Instance.Eac3toLog;
                if (_log == null)
                {
                    _log = MainForm.Instance.Log.Info("HD Streams Extractor");
                    MainForm.Instance.Eac3toLog = _log;
                }
            }
            else
            {
                _log = oLog.Add(new LogItem("eac3toInfo"));
            }

            foreach (string strPath in input)
            {
                _log.LogEvent("Input: " + strPath);
            }
            if (System.IO.Directory.Exists(input[0]))
            {
                oMode = OperatingMode.FolderBased;
            }
            else
            {
                oMode = OperatingMode.FileBased;
            }
            this.input = input;
            this.iFile = iFile;
        }
Пример #2
0
        /// <summary>
        /// checks if the files/folders can be processed as BluRay
        /// </summary>
        /// <returns>true if the files/folder can be processed as BluRay, false otherwise</returns>
        private bool getInputBluRayBased(OneClickSettings oSettings)
        {
            string path = Path.Combine(Path.Combine(this.strInput, "BDMV"), "PLAYLIST");

            if (!Directory.Exists(path))
            {
                return(false);
            }

            ChapterExtractor ex = new BlurayExtractor();

            using (frmStreamSelect frm = new frmStreamSelect(ex, SelectionMode.MultiExtended))
            {
                frm.Text = "Select your Titles";
                ex.GetStreams(this.strInput);
                if (frm.ChapterCount == 1 || (frm.ChapterCount > 1 && frm.ShowDialog() == DialogResult.OK))
                {
                    List <ChapterInfo> oChapterList = frm.SelectedMultipleChapterInfo;
                    if (oChapterList.Count > 0)
                    {
                        List <OneClickFilesToProcess> arrFilesToProcess = new List <OneClickFilesToProcess>();
                        MediaInfoFile iFile = null;

                        foreach (ChapterInfo oChapterInfo in oChapterList)
                        {
                            string strFile = this.strInput + @"\BDMV\PLAYLIST\" + oChapterInfo.SourceName;

                            if (iFile == null && File.Exists(strFile))
                            {
                                iFile = new MediaInfoFile(strFile, ref _log);
                                iFile.recommendIndexer(oSettings.IndexerPriority);
                            }
                            else
                            {
                                arrFilesToProcess.Add(new OneClickFilesToProcess(strFile, 1));
                            }
                        }
                        if (iFile != null)
                        {
                            oOneClickWindow.setInputData(iFile, arrFilesToProcess);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(false);
        }
Пример #3
0
        private void audioInput_FileSelected(FileBar sender, FileBarEventArgs args)
        {
            if (string.IsNullOrEmpty(audioInput.Filename))
                return;

            MediaInfoFile iFile = new MediaInfoFile(audioInput.Filename);
            if (!iFile.HasAudio)
            {
                audioInput.Filename = String.Empty;
                audioOutput.Filename = String.Empty;
                MessageBox.Show("This file cannot be processed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
                openAudioFile(audioInput.Filename);
        }
Пример #4
0
        /// <summary>
        /// checks if the input file can be processed
        /// </summary>
        /// <returns>true if the file can be processed, false otherwise</returns>
        private bool getInputFileBased(OneClickSettings oSettings)
        {
            if (File.Exists(this.strInput))
            {
                MediaInfoFile iFile = new MediaInfoFile(this.strInput, ref this._log);
                if (iFile.recommendIndexer(oSettings.IndexerPriority, true))
                {
                    return(getInputIndexerBased(iFile, oSettings));
                }
                else if (iFile.ContainerFileTypeString.Equals("AVS"))
                {
                    iFile.IndexerToUse = FileIndexerWindow.IndexType.NONE;
                    return(getInputIndexerBased(iFile, oSettings));
                }
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        /// checks if the input folder can be processed
        /// </summary>
        /// <returns>true if the folder can be processed, false otherwise</returns>
        private bool getInputFolderBased(OneClickSettings oSettings)
        {
            List <OneClickFilesToProcess> arrFilesToProcess = new List <OneClickFilesToProcess>();
            MediaInfoFile iFile = null;

            if (!Directory.Exists(this.strInput))
            {
                return(false);
            }

            foreach (string strFileName in Directory.GetFiles(this.strInput))
            {
                if (iFile == null)
                {
                    MediaInfoFile iFileTemp = new MediaInfoFile(strFileName, ref _log);
                    if (iFileTemp.recommendIndexer(oSettings.IndexerPriority, true))
                    {
                        iFile = iFileTemp;
                    }
                    else if (iFileTemp.ContainerFileTypeString.Equals("AVS"))
                    {
                        iFile = iFileTemp;
                        iFile.IndexerToUse = FileIndexerWindow.IndexType.NONE;
                    }
                    else
                    {
                        _log.LogEvent(strFileName + " cannot be processed as no indexer can be used. skipping...");
                    }
                }
                else
                {
                    arrFilesToProcess.Add(new OneClickFilesToProcess(strFileName, 1));
                }
            }
            if (iFile != null)
            {
                oOneClickWindow.setInputData(iFile, arrFilesToProcess);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        // batch processing
        public OneClickProcessing(OneClickWindow oWindow, List <OneClickFilesToProcess> arrFilesToProcess, OneClickSettings oSettings, LogItem oLog)
        {
            this.oOneClickWindow = oWindow;
            this._log            = oLog;
            this._bAbort         = false;

            List <OneClickFilesToProcess> arrFilesToProcessNew = new List <OneClickFilesToProcess>();
            MediaInfoFile iFile = null;

            foreach (OneClickFilesToProcess oFileToProcess in arrFilesToProcess)
            {
                if (iFile == null)
                {
                    MediaInfoFile iFileTemp = new MediaInfoFile(oFileToProcess.FilePath, ref _log, oFileToProcess.PGCNumber, oFileToProcess.AngleNumber);
                    if (iFileTemp.recommendIndexer(oSettings.IndexerPriority))
                    {
                        iFile = iFileTemp;
                    }
                    else if (iFileTemp.ContainerFileTypeString.Equals("AVS"))
                    {
                        iFile = iFileTemp;
                        iFile.IndexerToUse = FileIndexerWindow.IndexType.NONE;
                    }
                    else
                    {
                        _log.LogEvent(oFileToProcess.FilePath + " cannot be processed as no indexer can be used. skipping...");
                    }
                }
                else
                {
                    arrFilesToProcessNew.Add(oFileToProcess);
                }
            }
            if (iFile != null)
            {
                oOneClickWindow.setInputData(iFile, arrFilesToProcessNew);
            }
            else
            {
                oOneClickWindow.setInputData(null, new List <OneClickFilesToProcess>()); // not demuxable
            }
        }
Пример #7
0
 /// <summary>
 /// Check whether direct show can render the avi and then open it through an avisynth script.
 /// The avs is being used in order to allow more preview flexibility later.
 /// </summary>
 /// <param name="fileName">Input video file</param>
 private void openDirectShow(string fileName)
 {
     if (!File.Exists(fileName))
     {
         MessageBox.Show(fileName + " could not be found", "File Not Found", MessageBoxButtons.OK);
         return;
     }
     else
     {
         DirectShow ds = new DirectShow();
         if (!ds.checkRender(fileName)) // make sure graphedit can render the file
         {
             MessageBox.Show("Unable to render the file.\r\nYou probably don't have the correct filters installed", "Direct Show Error", MessageBoxButtons.OK);
         }
         else
         {
             string frameRateString = null;
             try
             {
                 MediaInfoFile info = new MediaInfoFile(fileName);
                 if (info.Info.HasVideo && info.Info.FPS > 0)
                     frameRateString = info.Info.FPS.ToString(System.Globalization.CultureInfo.InvariantCulture);
             }
             catch (Exception)
             { }
             string tempAvs = string.Format(
                     @"DirectShowSource(""{0}"", audio=false{1}, convertfps=true){2}",
                     fileName,
                     frameRateString == null ? string.Empty : (", fps=" + frameRateString),
                     this.flipVertical.Checked ? ".FlipVertical()" : string.Empty
                     );
             if (file != null)
                 file.Dispose();
            openVideo(tempAvs, fileName, true);
         }
     }
 }
Пример #8
0
 private bool getInputIndexerBased(MediaInfoFile iFile, OneClickSettings oSettings)
 {
     oOneClickWindow.setInputData(iFile, new List <OneClickFilesToProcess>());
     return(true);
 }
Пример #9
0
        /// <summary>
        /// checks if the files/folders can be processed as DVD
        /// </summary>
        /// <returns>true if the files/folder can be processed as DVD, false otherwise</returns>
        private bool getInputDVDBased(OneClickSettings oSettings)
        {
            string videoIFO;
            string path;

            if (File.Exists(this.strInput) && Path.GetExtension(this.strInput).ToLowerInvariant().Equals(".ifo"))
            {
                path     = Path.GetDirectoryName(this.strInput);
                videoIFO = this.strInput;
            }
            else if (File.Exists(this.strInput) && Path.GetExtension(this.strInput).ToLowerInvariant().Equals(".vob"))
            {
                path = Path.GetDirectoryName(this.strInput);
                if (Path.GetFileName(this.strInput).ToUpper(System.Globalization.CultureInfo.InvariantCulture).Substring(0, 4) == "VTS_")
                {
                    videoIFO = this.strInput.Substring(0, this.strInput.LastIndexOf("_")) + "_0.IFO";
                }
                else
                {
                    videoIFO = Path.ChangeExtension(this.strInput, ".IFO");
                }
                if (!File.Exists(videoIFO))
                {
                    return(false);
                }
                else
                {
                    this.strInput = videoIFO;
                }
            }
            else if (Directory.Exists(this.strInput) && Directory.GetFiles(this.strInput, "*.ifo").Length > 0)
            {
                path     = this.strInput;
                videoIFO = Path.Combine(path, "VIDEO_TS.IFO");
            }
            else if (Directory.Exists(Path.Combine(this.strInput, "VIDEO_TS")) && Directory.GetFiles(Path.Combine(this.strInput, "VIDEO_TS"), "*.IFO").Length > 0)
            {
                path     = Path.Combine(this.strInput, "VIDEO_TS");
                videoIFO = Path.Combine(path, "VIDEO_TS.IFO");
            }
            else
            {
                return(false);
            }

            ChapterExtractor ex = new DvdExtractor();

            using (frmStreamSelect frm = new frmStreamSelect(ex, SelectionMode.MultiExtended))
            {
                frm.Text = "Select your Titles";
                ex.GetStreams(this.strInput);
                if (frm.ChapterCount == 1 || (frm.ChapterCount > 1 && frm.ShowDialog() == DialogResult.OK))
                {
                    List <ChapterInfo> oChapterList = frm.SelectedMultipleChapterInfo;
                    if (oChapterList.Count > 0)
                    {
                        List <OneClickFilesToProcess> arrFilesToProcess = new List <OneClickFilesToProcess>();
                        MediaInfoFile iFile        = null;
                        int           iTitleNumber = 1;

                        foreach (ChapterInfo oChapterInfo in oChapterList)
                        {
                            string strVOBFile = Path.Combine(path, oChapterInfo.Title + "_1.VOB");

                            if (iFile == null && File.Exists(strVOBFile))
                            {
                                MediaInfoFile iFileTemp = new MediaInfoFile(strVOBFile, ref _log, oChapterInfo.TitleNumber);
                                if (iFileTemp.recommendIndexer(oSettings.IndexerPriority, false))
                                {
                                    iFile        = iFileTemp;
                                    iTitleNumber = oChapterInfo.TitleNumber;
                                }
                                else
                                {
                                    _log.LogEvent(strVOBFile + " cannot be processed as no indexer can be used. skipping...");
                                }
                            }
                            else
                            {
                                arrFilesToProcess.Add(new OneClickFilesToProcess(strVOBFile, oChapterInfo.TitleNumber));
                            }
                        }
                        if (iFile != null)
                        {
                            oOneClickWindow.setInputData(iFile, arrFilesToProcess);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(false);
        }
Пример #10
0
        void backgroundWorker_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            string data;

            if (!string.IsNullOrEmpty(e.Data))
            {
                data = e.Data.TrimStart('\b').Trim();

                if (!string.IsNullOrEmpty(data))
                {
                    // Feature line
                    // 2) 00216.mpls, 0:50:19
                    if (Regex.IsMatch(data, @"^[0-99]+\).+$", RegexOptions.Compiled))
                    {
                        try
                        {
                            features.Add(eac3to.Feature.Parse(data));
                        }
                        catch (Exception ex)
                        {
                            if (_log != null)
                            {
                                _log.LogValue("Error receiving output data", ex);
                            }
                        }

                        return;
                    }

                    // Feature name
                    // "Feature Name"
                    else if (Regex.IsMatch(data, "^\".+\"$", RegexOptions.Compiled))
                    {
                        // streams[streams.Count - 1].Name = Extensions.CapitalizeAll(data.Trim("\" .".ToCharArray())); //original
                        if (oMode == OperatingMode.FileBased)
                        {
                            features[0].Streams[features[0].Streams.Count - 1].Name = Extensions.CapitalizeAll(data.Trim("\" .".ToCharArray()));
                        }
                        else
                        {
                            features[features.Count - 1].Name = Extensions.CapitalizeAll(data.Trim("\" .".ToCharArray()));
                        }
                        return;
                    }

                    // Stream line on feature listing
                    // - h264/AVC, 1080p24 /1.001 (16:9)
                    else if (Regex.IsMatch(data, "^-.+$", RegexOptions.Compiled))
                    {
                        return;
                    }

                    // Playlist file listing
                    // [99+100+101+102+103+104+105+106+114].m2ts (blueray playlist *.mpls)
                    else if (Regex.IsMatch(data, @"^\[.+\].m2ts$", RegexOptions.Compiled))
                    {
                        foreach (string file in Regex.Match(data, @"\[.+\]").Value.Trim("[]".ToCharArray()).Split("+".ToCharArray()))
                        {
                            features[features.Count - 1].Files.Add(new File(file + ".m2ts", features[features.Count - 1].Files.Count + 1));
                        }

                        return;
                    }

                    // Stream listing feature header
                    // M2TS, 1 video track, 6 audio tracks, 9 subtitle tracks, 1:53:06
                    // EVO, 2 video tracks, 4 audio tracks, 8 subtitle tracks, 2:20:02
                    else if (Regex.IsMatch(data, "^M2TS, .+$", RegexOptions.Compiled) ||
                             Regex.IsMatch(data, "^EVO, .+$", RegexOptions.Compiled) ||
                             Regex.IsMatch(data, "^TS, .+$", RegexOptions.Compiled) ||
                             Regex.IsMatch(data, "^VOB, .+$", RegexOptions.Compiled) ||
                             Regex.IsMatch(data, "^MKV, .+$", RegexOptions.Compiled) ||
                             Regex.IsMatch(data, "^MKA, .+$", RegexOptions.Compiled)
                             )
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    // Stream line
                    // 8: AC3, English, 2.0 channels, 192kbps, 48khz, dialnorm: -27dB
                    else if (Regex.IsMatch(data, "^[0-99]+:.+$", RegexOptions.Compiled))
                    {
                        if (oMode == OperatingMode.FileBased)
                        {
                            try
                            {
                                if (features.Count == 0)
                                {
                                    Feature dummyFeature = new Feature();
                                    for (int i = 0; i < input.Count; i++)
                                    {
                                        if (System.IO.File.Exists(input[i]) && iFile == null)
                                        {
                                            iFile = new MediaInfoFile(input[i]);
                                        }
                                        if (iFile != null)
                                        {
                                            dummyFeature.Duration += TimeSpan.FromSeconds(Math.Ceiling(iFile.VideoInfo.FrameCount / iFile.VideoInfo.FPS));
                                            iFile = null;
                                        }
                                        dummyFeature.Files.Add(new File(System.IO.Path.GetFileName(input[i]), i + 1));
                                    }
                                    dummyFeature.Name        = System.IO.Path.GetFileName(input[0]);
                                    dummyFeature.Description = dummyFeature.Name + ", " + dummyFeature.Duration.ToString();
                                    features.Add(dummyFeature);
                                }
                                features[0].Streams.Add(eac3to.Stream.Parse(data));
                            }
                            catch (Exception ex)
                            {
                                if (_log != null)
                                {
                                    _log.LogValue("Error receiving output data", ex);
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                features[Int32.Parse(args.featureNumber) - 1].Streams.Add(Stream.Parse(data));
                            }
                            catch (Exception ex)
                            {
                                if (_log != null)
                                {
                                    _log.LogValue("Error receiving output data", ex);
                                }
                            }
                        }
                        return;
                    }

                    // Analyzing
                    // analyze: 100%
                    else if (Regex.IsMatch(data, "^analyze: [0-9]{1,3}%$", RegexOptions.Compiled))
                    {
                        if (backgroundWorker.IsBusy)
                        {
                            backgroundWorker.ReportProgress(int.Parse(Regex.Match(data, "[0-9]{1,3}").Value),
                                                            string.Format("Analyzing ({0}%)", int.Parse(Regex.Match(data, "[0-9]{1,3}").Value)));
                        }

                        return;
                    }

                    // Information line
                    // [a03] Creating file "audio.ac3"...
                    else if (Regex.IsMatch(data, @"^\[.+\] .+\.{3}$", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    else if (Regex.IsMatch(data, @"^\v .*...", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    else if (Regex.IsMatch(data, @"(core: .*)", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    else if (Regex.IsMatch(data, @"(embedded: .*)", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    // Creating file
                    // Creating file "C:\1_1_chapter.txt"...
                    else if (Regex.IsMatch(data, "^Creating file \".+\"\\.{3}$", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    // Processing
                    // process: 100%
                    else if (Regex.IsMatch(data, "^process: [0-9]{1,3}%$", RegexOptions.Compiled))
                    {
                        if (backgroundWorker.IsBusy)
                        {
                            backgroundWorker.ReportProgress(int.Parse(Regex.Match(data, "[0-9]{1,3}").Value),
                                                            string.Format("Processing ({0}%)", int.Parse(Regex.Match(data, "[0-9]{1,3}").Value)));
                        }

                        return;
                    }

                    // Progress
                    // progress: 100%
                    else if (Regex.IsMatch(data, "^progress: [0-9]{1,3}%$", RegexOptions.Compiled))
                    {
                        if (backgroundWorker.IsBusy)
                        {
                            backgroundWorker.ReportProgress(int.Parse(Regex.Match(data, "[0-9]{1,3}").Value),
                                                            string.Format("Progress ({0}%)", int.Parse(Regex.Match(data, "[0-9]{1,3}").Value)));
                        }

                        return;
                    }

                    // Done
                    // Done.
                    else if (data.Equals("Done."))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    // unusual video framerate
                    // v02 The video framerate is correct, but rather unusual.
                    else if (data.Contains("The video framerate is correct, but rather unusual"))
                    {
                        if (_log != null)
                        {
                            _log.LogEvent(data);
                        }
                        return;
                    }

                    #region Errors
                    // Source file not found
                    // Source file "x:\" not found.
                    else if (Regex.IsMatch(data, "^Source file \".*\" not found.$", RegexOptions.Compiled))
                    {
                        if (_log != null)
                        {
                            _log.Error(data);
                        }
                        return;
                    }

                    // Format of Source file not detected
                    // The format of the source file could not be detected.
                    else if (data.Equals("The format of the source file could not be detected."))
                    {
                        if (_log != null)
                        {
                            _log.Error(data);
                        }
                        return;
                    }

                    // Audio conversion not supported
                    // This audio conversion is not supported.
                    else if (data.Equals("This audio conversion is not supported."))
                    {
                        if (_log != null)
                        {
                            _log.Error(data);
                        }
                        return;
                    }
                    #endregion

                    // Unknown line
                    else
                    {
                        if (_log != null)
                        {
                            _log.Warn(string.Format("Unknown line: \"{0}\"", data));
                        }
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// checks if the files/folders can be processed as DVD/Blu-ray
        /// </summary>
        /// <returns>true if the files/folder can be processed as DVD or Blu-ray, false otherwise</returns>
        private bool getInputDVDorBlurayBased(OneClickSettings oSettings)
        {
            if (FileUtil.RegExMatch(this.strInput, @"\\playlist\\\d{5}\.mpls\z", true))
            {
                // mpls file selected - if Blu-ray structure exists, the playlist will be directly openend
                string checkFolder = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(this.strInput)), "STREAM");
                if (Directory.Exists(checkFolder) && Directory.GetFiles(checkFolder, "*.m2ts").Length > 0)
                {
                    return(false);
                }
            }

            using (frmStreamSelect frm = new frmStreamSelect(this.strInput, SelectionMode.MultiExtended))
            {
                // 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)
                {
                    // abort as the user clicked not on OK
                    this._bAbort = true;
                    return(false);
                }

                // check how many playlists have been selected
                List <ChapterInfo> oChapterList = frm.SelectedMultipleChapterInfo;
                if (oChapterList.Count == 0)
                {
                    return(false);
                }

                List <OneClickFilesToProcess> arrFilesToProcess = new List <OneClickFilesToProcess>();
                MediaInfoFile iFile = null;

                foreach (ChapterInfo oChapterInfo in oChapterList)
                {
                    string strSourceFile = string.Empty;
                    if (frm.IsDVDSource)
                    {
                        strSourceFile = Path.Combine(Path.GetDirectoryName(oChapterInfo.SourceFilePath), oChapterInfo.Title + "_1.VOB");
                    }
                    else
                    {
                        strSourceFile = oChapterInfo.SourceFilePath;
                    }

                    if (!File.Exists(strSourceFile))
                    {
                        _log.LogEvent(strSourceFile + " cannot be found. skipping...");
                        continue;
                    }

                    if (iFile == null)
                    {
                        MediaInfoFile iFileTemp = new MediaInfoFile(strSourceFile, ref _log, frm.IsDVDSource ? oChapterInfo.PGCNumber : 1,
                                                                    frm.IsDVDSource ? oChapterInfo.AngleNumber : 0);
                        if (iFileTemp.recommendIndexer(oSettings.IndexerPriority))
                        {
                            iFile = iFileTemp;
                        }
                        else
                        {
                            _log.LogEvent(strSourceFile + " cannot be processed as no indexer can be used. skipping...");
                        }
                    }
                    else
                    {
                        arrFilesToProcess.Add(new OneClickFilesToProcess(strSourceFile, frm.IsDVDSource ? oChapterInfo.PGCNumber : 1,
                                                                         frm.IsDVDSource ? oChapterInfo.AngleNumber : 0));
                    }
                }

                if (iFile != null)
                {
                    oOneClickWindow.setInputData(iFile, arrFilesToProcess);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }