Beispiel #1
0
        public static List <DVDTitle> Titles(string videoTSDir)
        {
            List <DVDTitle> ret = new List <DVDTitle>();

            string videoIFO = Path.Combine(videoTSDir, "VIDEO_TS.IFO");

            if (File.Exists(videoIFO))
            {
                byte[] bytRead = new byte[4];
                long   VMG_PTT_STPT_Position = ToFilePosition(GetFileBlock(videoIFO, 0xC4, 4));
                int    titlePlayMaps         = ToInt16(GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));
                string longestIfo            = GetLongestIFO(videoTSDir);
                for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
                {
                    DVDTitle title = new DVDTitle()
                    {
                        TitleNumber = currentTitle
                    };
                    long   titleInfoStart      = 8 + ((currentTitle - 1) * 12);
                    int    titleSetNumber      = GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
                    int    titleSetTitleNumber = IFOUtilities.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
                    string vtsIFO = Path.Combine(videoTSDir, string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
                    if (File.Exists(vtsIFO) == false)
                    {
                        Trace.WriteLine(string.Format("IFOUtils.Titles: VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
                        continue;
                    }
                    byte[]      b     = IFOUtilities.GetFileBlock(vtsIFO, 0x200, 2);
                    VideoValues video = VideoValues.ReadVideoSpecs(b[0], b[1]);
                    title.Main        = Path.GetFileName(longestIfo) == Path.GetFileName(vtsIFO);
                    title.File        = "vts " + titleSetNumber;
                    title.AspectRatio = video.AspectRatio;
                    title.Resolution  = video.Resolution;
                    title.Chapters    = Chapters(vtsIFO, titleSetTitleNumber);
                    title.AudioTracks = AudioTracks(vtsIFO);
                    title.Subtitles   = SubTitleTracks(vtsIFO);
                    title.Duration    = DVDTitle.GetTotalTimeSpan(title.Chapters);
                    //if (title.Duration.TotalSeconds > 10)
                    ret.Add(title);
                    //else
                    //    Trace.WriteLine(string.Format("IFOUtils.Titles: Duration < 10s, ignoring: {0}", Path.GetFileName(vtsIFO)));
                }
            }
            else
            {
                Trace.WriteLine(string.Format("IFOUtilities.Titles: Cannot analyze DVD, file {0} not found", videoIFO));
            }
            return(ret);
        }
Beispiel #2
0
 public static string GetLongestIFO(string directory)
 {
     if (Directory.Exists(directory))
     {
         string   longestFile = null;
         TimeSpan max         = TimeSpan.Zero;
         foreach (string ifoFile in Directory.GetFiles(directory, "VTS_*.IFO"))
         {
             List <DVDChapter> chapters = Chapters(Path.Combine(directory, ifoFile), -1);
             if (chapters != null)
             {
                 TimeSpan time = DVDTitle.GetTotalTimeSpan(chapters);
                 if (time > max)
                 {
                     longestFile = ifoFile;
                     max         = time;
                 }
             }
         }
         return(longestFile);
     }
     return(null);
 }
 void PlayTitle(DVDTitle title)
 {
     if (m_dvdCtrl == null)
         PreviewInit();
     IDvdCmd cmd;
     DvdHMSFTimeCode time = new DvdHMSFTimeCode() { bSeconds = 10 };
     m_dvdCtrl.PlayAtTimeInTitle(title.TitleNumber, time, DvdCmdFlags.SendEvents, out cmd);
 }
 void FillSubtitle(DVDTitle title)
 {
     txtSubtitles.Text = string.Empty;
     foreach (DVDSubtitle st in title.Subtitles)
         txtSubtitles.Text += ", " + st.LanguageID;
     txtSubtitles.Text = txtSubtitles.Text.TrimStart(',', ' ');
 }
 void FillAudioTrack(DVDTitle title)
 {
     txtAudioTracks.Text = string.Empty;
     foreach (DVDAudioTrack at in title.AudioTracks)
     {
         txtAudioTracks.Text += ", " + at.LanguageID + " (" + at.Format + "," + at.SubFormat;
         if (at.Extension != AudioExtension.Normal && at.Extension != AudioExtension.Unspecified)
             txtAudioTracks.Text += ", " + DVDAudioTrack.GetExtension(at.Extension);
         txtAudioTracks.Text += ")";
     }
     txtAudioTracks.Text = txtAudioTracks.Text.TrimStart(',', ' ');
 }
        public static List<DVDTitle> Titles(string videoTSDir)
        {
            List<DVDTitle> ret = new List<DVDTitle>();

            string videoIFO = Path.Combine(videoTSDir, "VIDEO_TS.IFO");
            if (File.Exists(videoIFO))
            {
                byte[] bytRead = new byte[4];
                long VMG_PTT_STPT_Position = ToFilePosition(GetFileBlock(videoIFO, 0xC4, 4));
                int titlePlayMaps = ToInt16(GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));
                string longestIfo = GetLongestIFO(videoTSDir);
                for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
                {
                    DVDTitle title = new DVDTitle() { TitleNumber = currentTitle };
                    long titleInfoStart = 8 + ((currentTitle - 1) * 12);
                    int titleSetNumber = GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
                    int titleSetTitleNumber = IFOUtilities.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
                    string vtsIFO = Path.Combine(videoTSDir, string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
                    if (File.Exists(vtsIFO) == false)
                    {
                        Trace.WriteLine(string.Format("IFOUtils.Titles: VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
                        continue;
                    }
                    byte[] b = IFOUtilities.GetFileBlock(vtsIFO, 0x200, 2);
                    VideoValues video = VideoValues.ReadVideoSpecs(b[0], b[1]);
                    title.Main = Path.GetFileName(longestIfo) == Path.GetFileName(vtsIFO);
                    title.File = "vts " + titleSetNumber;
                    title.AspectRatio = video.AspectRatio;
                    title.Resolution = video.Resolution;
                    title.Chapters = Chapters(vtsIFO, titleSetTitleNumber);
                    title.AudioTracks = AudioTracks(vtsIFO);
                    title.Subtitles = SubTitleTracks(vtsIFO);
                    title.Duration = DVDTitle.GetTotalTimeSpan(title.Chapters);
                    //if (title.Duration.TotalSeconds > 10)
                        ret.Add(title);
                    //else
                    //    Trace.WriteLine(string.Format("IFOUtils.Titles: Duration < 10s, ignoring: {0}", Path.GetFileName(vtsIFO)));
                }
            }
            else
                Trace.WriteLine(string.Format("IFOUtilities.Titles: Cannot analyze DVD, file {0} not found", videoIFO));
            return ret;
        }