Ejemplo n.º 1
0
        private MoovInfo?ReadMoovInfo()
        {
            var moovBox = FindBox(moov);

            if (moovBox != null)
            {
                var     moovData = new MoovInfo();
                var     tracks   = new List <TrakInfo>();
                var     maxLen   = moovBox.Value.BoxOffset + moovBox.Value.Offset;
                BoxInfo?box      = null;
                do
                {
                    box = NextBox(maxLen);
                    if (box != null)
                    {
                        if (box.Value.Type.Check(mvhd))
                        {
                            ReadMvhd(ref moovData);
                        }
                        if (box.Value.Type.Check(trak))
                        {
                            tracks.Add(ReadTrak(box.Value));
                        }
                        SeekNext(box.Value);
                    }
                } while (!(box == null || box.Value.Last));
                moovData.Tracks = tracks.ToArray();
                return(moovData);
            }
            return(null);
        }
Ejemplo n.º 2
0
        private void ReadMvhd(ref MoovInfo moovData)
        {
            var v = new byte[1];

            stream.Read(v, 1);
            var isv8 = v[0] == 1;

            stream.Seek(SeekOrigin.Current, 3 + (isv8 ? 8 + 8 : 4 + 4));
            moovData.TimeUnitPerSecond = ReadUint32();
        }
Ejemplo n.º 3
0
        private void ReadChapters(MoovInfo moovBox)
        {
            var soundBox = moovBox.Tracks.Where(b => b.Type == "soun").ToArray();

            if (soundBox.Length == 0)
            {
                return;
            }
            if (soundBox[0].Chaps != null && soundBox[0].Chaps.Length > 0)
            {
                var cb      = new HashSet <uint>(soundBox[0].Chaps);
                var textBox = moovBox.Tracks.Where(b => b.Type == "text" && cb.Contains(b.Id)).ToArray();
                if (textBox.Length == 0)
                {
                    return;
                }
                ReadChaptersText(textBox[0]);
            }
        }