Beispiel #1
0
        List<Clip> GetClips(byte[] data)
        {
            List<Clip> chapterClips = new List<Clip>();

              int playlistIndex =
                    ((int)data[8] << 24) +
                    ((int)data[9] << 16) +
                    ((int)data[10] << 8) +
                    ((int)data[11]);

              // TODO: Hack for bad TSRemux output.
              int playlistLength = data.Length - playlistIndex - 4;
              int playlistLengthCorrect =
              ((int)data[playlistIndex] << 24) +
              ((int)data[playlistIndex + 1] << 16) +
              ((int)data[playlistIndex + 2] << 8) +
              ((int)data[playlistIndex + 3]);

              byte[] playlistData = new byte[playlistLength];
              Array.Copy(data, playlistIndex + 4,
              playlistData, 0, playlistData.Length);

              int streamFileCount = (((int)playlistData[2] << 8) + (int)playlistData[3]);

              int streamFileOffset = 6;
              for (int streamFileIndex = 0; streamFileIndex < streamFileCount; streamFileIndex++)
              {
            byte condition = (byte)(playlistData[streamFileOffset + 12] & 0xF);

            ulong timeIn =
            ((ulong)playlistData[streamFileOffset + 14] << 24) +
            ((ulong)playlistData[streamFileOffset + 15] << 16) +
            ((ulong)playlistData[streamFileOffset + 16] << 8) +
            ((ulong)playlistData[streamFileOffset + 17]);

            ulong timeOut =
            ((ulong)playlistData[streamFileOffset + 18] << 24) +
            ((ulong)playlistData[streamFileOffset + 19] << 16) +
            ((ulong)playlistData[streamFileOffset + 20] << 8) +
            ((ulong)playlistData[streamFileOffset + 21]);

            Clip streamClip = new Clip();

            streamClip.TimeIn = (double)timeIn / 45000D;
            streamClip.TimeOut = (double)timeOut / 45000D;
            streamClip.Length = streamClip.TimeOut - streamClip.TimeIn;
            streamClip.RelativeTimeIn = chapterClips.Sum(c => c.Length);
            streamClip.RelativeTimeOut = streamClip.RelativeTimeIn + streamClip.Length;
            chapterClips.Add(streamClip);

            //ignore angles

            streamFileOffset += 2 +
            ((int)playlistData[streamFileOffset] << 8) +
            ((int)playlistData[streamFileOffset + 1]);
              }
              return chapterClips;
        }