Exemplo n.º 1
0
        // http://dvd.sourceforge.net/dvdinfo/ifo.html#vidatt
        public static VideoValues ReadVideoSpecs(byte b1, byte b2)
        {
            int byte0_high = (b1 & 0xF0) >> 4;
            int byte0_low  = (b1 & 0x0F);
            int byte1_high = (b2 & 0xF0) >> 4;
            int byte1_low  = (b2 & 0x0F);

            VideoValues result = new VideoValues();

            result.DisallowAutoLetterbox = (byte0_low & 1) != 0;
            result.DisallowAutoPanScan   = (byte0_low & 2) != 0;
            result.AspectRatio           = (byte0_low & 0x0C) == 0 ? 1.33f : 1.78f;
            if (((byte0_low & 0x0C) != 0) && ((byte0_low & 0x0C) != 0x0C))
            {
                throw new Exception("the aspectRatio is not valid");
            }
            result.Ntsc            = (byte0_high & 1) == 0;
            result.Pal             = (byte0_high & 1) != 0;
            result.Mpeg1           = (byte0_high & 0x0C) == 0;
            result.Mpeg2           = (byte0_high & 0x0C) == 4;
            result.Film            = (byte1_low & 1) != 0;
            result.LetterBoxedMode = (byte1_low & 2) != 0;

            // 0 = 720x480 (720x576)
            // 1 = 704x480 (704x576)
            // 2 = 352x480 (352x576)
            // 3 = 352x240 (352x288)
            if (result.Ntsc)
            {
                switch ((byte1_low >> 2) & 0x03)
                {
                case 0: result.Resolution = new Size(720, 480); break;

                case 1: result.Resolution = new Size(704, 480); break;

                case 2: result.Resolution = new Size(352, 480); break;

                case 3: result.Resolution = new Size(352, 240); break;
                }
            }
            else
            {
                switch ((byte1_low >> 2) & 0x03)
                {
                case 0: result.Resolution = new Size(720, 576); break;

                case 1: result.Resolution = new Size(704, 576); break;

                case 2: result.Resolution = new Size(352, 576); break;

                case 3: result.Resolution = new Size(352, 288); break;
                }
            }
            result.BitRate_Vbr  = (byte1_high & 1) == 0;
            result.BitRate_Cbr  = (byte1_high & 1) != 0;
            result.CC_line21_f2 = (byte1_high & 4) != 0;
            result.CC_line21_f1 = (byte1_high & 8) != 0;
            return(result);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        // http://dvd.sourceforge.net/dvdinfo/ifo.html#vidatt
        public static VideoValues ReadVideoSpecs(byte b1, byte b2)
        {
            int byte0_high = (b1 & 0xF0) >> 4;
            int byte0_low = (b1 & 0x0F);
            int byte1_high = (b2 & 0xF0) >> 4;
            int byte1_low = (b2 & 0x0F);

            VideoValues result = new VideoValues();
            result.DisallowAutoLetterbox = (byte0_low & 1) != 0;
            result.DisallowAutoPanScan = (byte0_low & 2) != 0;
            result.AspectRatio = (byte0_low & 0x0C) == 0 ? 1.33f : 1.78f;
            if (((byte0_low & 0x0C) != 0) && ((byte0_low & 0x0C) != 0x0C))
                throw new Exception("the aspectRatio is not valid");
            result.Ntsc = (byte0_high & 1) == 0;
            result.Pal = (byte0_high & 1) != 0;
            result.Mpeg1 = (byte0_high & 0x0C) == 0;
            result.Mpeg2 = (byte0_high & 0x0C) == 4;
            result.Film = (byte1_low & 1) != 0;
            result.LetterBoxedMode = (byte1_low & 2) != 0;

            // 0 = 720x480 (720x576)
            // 1 = 704x480 (704x576)
            // 2 = 352x480 (352x576)
            // 3 = 352x240 (352x288)
            if (result.Ntsc)
                switch ((byte1_low >> 2) & 0x03)
                {
                    case 0: result.Resolution = new Size(720, 480); break;
                    case 1: result.Resolution = new Size(704, 480); break;
                    case 2: result.Resolution = new Size(352, 480); break;
                    case 3: result.Resolution = new Size(352, 240); break;
                }
            else
                switch ((byte1_low >> 2) & 0x03)
                {
                    case 0: result.Resolution = new Size(720, 576); break;
                    case 1: result.Resolution = new Size(704, 576); break;
                    case 2: result.Resolution = new Size(352, 576); break;
                    case 3: result.Resolution = new Size(352, 288); break;
                }
            result.BitRate_Vbr = (byte1_high & 1) == 0;
            result.BitRate_Cbr = (byte1_high & 1) != 0;
            result.CC_line21_f2 = (byte1_high & 4) != 0;
            result.CC_line21_f1 = (byte1_high & 8) != 0;
            return result;
        }