Esempio n. 1
0
        public static void GetAppVersions(string encPath = "", string javaPath = "")
        {
            if (String.IsNullOrEmpty(encPath))
                encPath = AppSettings.ToolsPath;
            if (String.IsNullOrEmpty(javaPath))
                javaPath = AppSettings.JavaInstallPath;

            X264 x264Enc = new X264();
            AppSettings.Lastx264Ver = x264Enc.GetVersionInfo(encPath,false);

            if (Environment.Is64BitOperatingSystem)
                AppSettings.Lastx26464Ver = x264Enc.GetVersionInfo(encPath, true);

            FfMpeg ffmpeg = new FfMpeg();
            AppSettings.LastffmpegVer = ffmpeg.GetVersionInfo(encPath, false);

            if (Environment.Is64BitOperatingSystem)
                AppSettings.Lastffmpeg64Ver = ffmpeg.GetVersionInfo(encPath, true);

            Eac3To eac3To = new Eac3To();
            AppSettings.Lasteac3ToVer = eac3To.GetVersionInfo(encPath);

            LsDvd lsdvd = new LsDvd();
            AppSettings.LastlsdvdVer = lsdvd.GetVersionInfo(encPath);

            MkvMerge mkvMerge = new MkvMerge();
            AppSettings.LastMKVMergeVer = mkvMerge.GetVersionInfo(encPath);

            MPlayer mplayer = new MPlayer();
            AppSettings.LastMplayerVer = mplayer.GetVersionInfo(encPath);

            TsMuxeR tsmuxer = new TsMuxeR();
            AppSettings.LastTSMuxerVer = tsmuxer.GetVersionInfo(encPath);

            MJpeg mjpeg = new MJpeg();
            AppSettings.LastMJPEGToolsVer = mjpeg.GetVersionInfo(encPath);

            DvdAuthor dvdauthor = new DvdAuthor();
            AppSettings.LastDVDAuthorVer = dvdauthor.GetVersionInfo(encPath);

            MP4Box mp4Box = new MP4Box();
            AppSettings.LastMp4BoxVer = mp4Box.GetVersionInfo(encPath);

            HcEnc hcenc = new HcEnc();
            AppSettings.LastHcEncVer = hcenc.GetVersionInfo(encPath);

            OggEnc ogg = new OggEnc();
            AppSettings.LastOggEncVer = ogg.GetVersionInfo(encPath);

            NeroAACEnc aac = new NeroAACEnc();
            AppSettings.LastNeroAacEncVer = aac.GetVersionInfo(encPath);

            Lame lame = new Lame();
            AppSettings.LastLameVer = lame.GetVersionInfo(encPath);

            VpxEnc vpxEnc = new VpxEnc();
            AppSettings.LastVpxEncVer = vpxEnc.GetVersionInfo(encPath);

            if (!String.IsNullOrEmpty(javaPath))
            {
                BdSup2SubTool bdSup2Sub = new BdSup2SubTool();
                AppSettings.LastBDSup2SubVer = bdSup2Sub.GetVersionInfo(encPath, javaPath);
            }

            #region Get AviSynth Version

            IGraphBuilder graphBuilder = (IGraphBuilder)new FilterGraph();

            string avsFile = AviSynthGenerator.GenerateTestFile();

            int result = graphBuilder.RenderFile(avsFile, null);

            Log.DebugFormat("RenderFile Result: {0}", result);

            if (result < 0)
                Log.Debug("AviSynth is not installed");
            else
            {
                FileVersionInfo ver = FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "avisynth.dll"));
                string appVer = String.Format("{0:g}.{1:g}.{2:g}.{3:g}", ver.FileMajorPart, ver.FileMinorPart,
                                              ver.FileBuildPart, ver.FilePrivatePart);
                Log.DebugFormat("Avisynth version {0:s} installed", appVer);
                AppSettings.LastAviSynthVer = appVer;
            }

            File.Delete(avsFile);
            #endregion

            GetAviSynthPluginsVer();
            GetUpdaterVersion();

            AppSettings.UpdateVersions = false;
            AppSettings.SaveSettings();
        }
Esempio n. 2
0
        private void GetDVDTitleList()
        {
            string strChapters = Processing.GetResourceString("streamselect_chapters");
            string strVideo = Processing.GetResourceString("streamselect_video");
            string strAudio = Processing.GetResourceString("streamselect_audio");
            string strSubtitles = Processing.GetResourceString("streamselect_subtitles");

            string dvdTitleFormat = Processing.GetResourceString("streamselect_dvd_general");
            string dvdAudioFormat = Processing.GetResourceString("streamselect_dvd_audio");
            string dvdSubFormat = Processing.GetResourceString("streamselect_dvd_subtitle");

            const string dvdVideoStreamFormat = "MPEG-2 {1:g}x{2:g} {4}{5} {0} {3:f} fps";

            LsDvd lsdvd = new LsDvd();
            string lines = lsdvd.GetDvdInfo(JobInfo.InputFile);

            XmlDocument dvdInfo = new XmlDocument();
            dvdInfo.LoadXml(lines);

            if (dvdInfo.DocumentElement == null) return;

            XmlNodeList tracks = dvdInfo.DocumentElement.SelectNodes("//track");
            XmlNode longestTrack = dvdInfo.DocumentElement.SelectSingleNode("//longest_track");

            if (longestTrack == null) return;
            if (tracks == null) return;

            int longest = Convert.ToInt32(longestTrack.InnerText);

            foreach (XmlNode track in tracks)
            {
                int videoId = 0;
                float fps = 0;
                string videoFormat = string.Empty;
                string aspect = string.Empty;
                int width = 0;
                int height = 0;
                string letterboxed = string.Empty;
                int vtsID = 0;
                float lengthTemp = 0;

                XmlNode tempNode = track.SelectSingleNode("ix");
                if (tempNode != null)
                    videoId = Convert.ToInt32(tempNode.InnerText);

                tempNode = track.SelectSingleNode("fps");
                if (tempNode != null)
                    fps = Convert.ToSingle(tempNode.InnerText, AppSettings.CInfo);

                tempNode = track.SelectSingleNode("format");
                if (tempNode != null)
                    videoFormat = tempNode.InnerText;

                tempNode = track.SelectSingleNode("aspect");
                if (tempNode != null)
                    aspect = tempNode.InnerText;

                tempNode = track.SelectSingleNode("width");
                if (tempNode != null)
                    width = Convert.ToInt32(tempNode.InnerText);

                tempNode = track.SelectSingleNode("height");
                if (tempNode != null)
                    height = Convert.ToInt32(tempNode.InnerText);

                tempNode = track.SelectSingleNode("df");
                if (tempNode != null)
                {
                    string df = tempNode.InnerText;
                    letterboxed = df == "?" ? string.Empty : " (" + df + ")";
                }

                tempNode = track.SelectSingleNode("vts");
                if (tempNode != null)
                    vtsID = Convert.ToInt32(tempNode.InnerText);

                tempNode = track.SelectSingleNode("length");
                if (tempNode != null)
                    lengthTemp = Convert.ToSingle(tempNode.InnerText, AppSettings.CInfo);

                TimeSpan length = new TimeSpan(0, 0, 0, (int) Math.Truncate(lengthTemp),
                                               (int) ((lengthTemp - Math.Truncate(lengthTemp))*1000));

                XmlNodeList audioTracks = track.SelectNodes("audio");
                XmlNodeList chapters = track.SelectNodes("chapter");
                XmlNodeList subtitles = track.SelectNodes("subp");

                List<TimeSpan> tempChapters = new List<TimeSpan>();

                DateTime duration = new DateTime();
                duration = duration.AddSeconds(length.TotalSeconds);

                string treeRoot = string.Format(dvdTitleFormat, videoId, duration.ToString("H:mm:ss.fff"));

                Dictionary<string, object> treeData = new Dictionary<string, object>
                                                          {{"Name", JobInfo.InputFile}, {"TrackID", videoId}};

                TreeNode root = new TreeNode
                    {
                        ID = _treeNodeID++,
                        Name = treeRoot,
                        Data = treeData,
                        Children = new List<TreeNode>(),
                        IsChecked = true,
                    };
                root.IsExpanded = root.IsChecked;
                _tree.Add(root);

                TreeNode chaptersTree = CreateNode(root, strChapters, null);
                TreeNode videoTree = CreateNode(root, strVideo, null);
                TreeNode audioTree = CreateNode(root, strAudio, null);
                TreeNode subTree = CreateNode(root, strSubtitles, null);

                if (chapters != null && chapters.Count > 0)
                {
                    TimeSpan chapLength = new TimeSpan(0, 0, 0, 0, 0);
                    tempChapters.Add(chapLength);
                }
                if (chapters != null)
                    tempChapters.AddRange(
                        chapters.Cast<XmlNode>().Select(
                            chapterTemp =>
                                {
                                    XmlNode node = chapterTemp.SelectSingleNode("length");
                                    return node != null ? Convert.ToSingle(node.InnerText, AppSettings.CInfo) : 0;
                                }).Select(
                                    chapterLengthTemp =>
                                    new TimeSpan(0, 0, 0, (int) Math.Truncate(chapterLengthTemp),
                                                 (int) ((chapterLengthTemp - Math.Truncate(chapterLengthTemp))*1000))));

                if (tempChapters.Count > 0)
                {
                    string chaptersFormat = string.Format("{0:0} {1}", tempChapters.Count, strChapters);
                    CreateNode(chaptersTree, chaptersFormat, tempChapters);
                }

                string videoStream = string.Format(dvdVideoStreamFormat, videoFormat, width, height, fps, aspect,
                                                   letterboxed);

                VideoInfo vid = new VideoInfo
                    {
                        VtsId = vtsID,
                        TrackId = videoId,
                        StreamId = 1,
                        FPS = fps,
                        Interlaced = true,
                        Format = "MPEG-2",
                        FrameCount = 0,
                        Width = width,
                        Height = height,
                        Encoded = false,
                        IsRawStream = false,
                        DemuxStreamNames = new List<string>(),
                        StreamSize = 0,
                        Length = lengthTemp
                    };

                if (aspect != "4/3")
                    Single.TryParse(aspect, NumberStyles.Number, AppSettings.CInfo, out vid.AspectRatio);
                else
                    vid.AspectRatio = 4f / 3f;

                Processing.GetFPSNumDenom(fps, out vid.FrameRateEnumerator, out vid.FrameRateDenominator);

                CreateNode(videoTree, videoStream, vid);

                int audioTracksCount = 0;

                if (audioTracks != null)
                {
                    audioTracksCount = audioTracks.Count;
                    foreach (XmlNode audio in audioTracks)
                    {
                        int audioID = 0;
                        string langCode = string.Empty;
                        string language = string.Empty;
                        string format = string.Empty;
                        int frequency = 0;
                        string quantization = string.Empty;
                        int channels = 0;
                        string content = string.Empty;
                        int streamID = 0;

                        tempNode = audio.SelectSingleNode("ix");
                        if (tempNode != null)
                            audioID = Convert.ToInt32(tempNode.InnerText);

                        tempNode = audio.SelectSingleNode("langcode");
                        if (tempNode != null)
                            langCode = tempNode.InnerText;

                        tempNode = audio.SelectSingleNode("language");
                        if (tempNode != null)
                            language = tempNode.InnerText;

                        tempNode = audio.SelectSingleNode("format");
                        if (tempNode != null)
                            format = tempNode.InnerText;

                        tempNode = audio.SelectSingleNode("frequency");
                        if (tempNode != null)
                            frequency = Convert.ToInt32(tempNode.InnerText);

                        tempNode = audio.SelectSingleNode("quantization");
                        if (tempNode != null)
                            quantization = tempNode.InnerText;

                        tempNode = audio.SelectSingleNode("channels");
                        if (tempNode != null)
                            channels = Convert.ToInt32(tempNode.InnerText);

                        tempNode = audio.SelectSingleNode("content");
                        if (tempNode != null)
                            content = tempNode.InnerText;

                        tempNode = audio.SelectSingleNode("streamid");
                        if (tempNode != null)
                            streamID = Int32.Parse(tempNode.InnerText.Replace("0x", string.Empty),
                                                   NumberStyles.HexNumber);

                        string audioStream = string.Format(dvdAudioFormat, audioID, streamID, langCode, language,
                                                           content, format, channels, frequency, quantization);

                        AudioInfo aud = new AudioInfo
                            {
                                Format = format,
                                FormatProfile = string.Empty,
                                Id = audioID,
                                StreamId = streamID,
                                LangCode = langCode,
                                TempFile = string.Empty,
                                OriginalId = audioID,
                                Delay = 0,
                                Bitrate = 0,
                                SampleRate = frequency,
                                ChannelCount = channels,
                                ShortLang = langCode,
                                StreamSize = 0,
                                IsHdStream = false
                            };

                        CreateNode(audioTree, audioStream, aud);
                    }
                }

                if (subtitles == null) continue;
                foreach (XmlNode subtitle in subtitles)
                {
                    int subID = 0;
                    string langCode = string.Empty;
                    string language = string.Empty;
                    string content = string.Empty;
                    int streamID = 0;

                    tempNode = subtitle.SelectSingleNode("ix");
                    if (tempNode != null)
                        subID = Convert.ToInt32(tempNode.InnerText);

                    tempNode = subtitle.SelectSingleNode("langcode");
                    if (tempNode != null)
                        langCode = tempNode.InnerText;

                    tempNode = subtitle.SelectSingleNode("language");
                    if (tempNode != null)
                        language = tempNode.InnerText;

                    tempNode = subtitle.SelectSingleNode("content");
                    if (tempNode != null)
                        content = tempNode.InnerText;

                    tempNode = subtitle.SelectSingleNode("streamid");
                    if (tempNode != null)
                        streamID = Int32.Parse(tempNode.InnerText.Replace("0x", string.Empty),
                                               NumberStyles.HexNumber);

                    string subtitleStream = string.Format(dvdSubFormat, subID, streamID, langCode, language, content);

                    SubtitleInfo subInfo = new SubtitleInfo
                        {
                            Id = subID + audioTracksCount,
                            StreamId = streamID,
                            TempFile = string.Empty,
                            LangCode = langCode,
                            Format = "VobSub",
                            Delay = 0,
                            StreamSize = 0
                        };

                    CreateNode(subTree, subtitleStream, subInfo);
                }
            }
            _defaultSelection = longest - 1;
        }