Пример #1
0
        private bool findCammBox(BinaryReader movieIn, long endPosition)
        {
            byte[] mdia = Encoding.ASCII.GetBytes(@"mdia");
            byte[] minf = Encoding.ASCII.GetBytes(@"minf");
            byte[] stbl = Encoding.ASCII.GetBytes(@"stbl");
            byte[] stsd = Encoding.ASCII.GetBytes(@"stsd");
            byte[] camm = Encoding.ASCII.GetBytes(@"camm");

            do
            {
                var next = new atomlib.Container();
                next.ReadBoxHeader(movieIn);
                System.Console.WriteLine("fCB - " + System.Text.Encoding.ASCII.GetString(next.name));
                if (next.CompareName(mdia))
                {
                    if (findContainer(minf, movieIn, movieIn.BaseStream.Position + next.length - next.headerLength))
                    {
                        if (findContainer(stbl, movieIn, movieIn.BaseStream.Position + next.length - next.headerLength))
                        {
                            if (findContainer(stsd, movieIn, movieIn.BaseStream.Position + next.length - next.headerLength))
                            {
                                movieIn.BaseStream.Seek(8, SeekOrigin.Current);
                                return(findContainer(camm, movieIn, movieIn.BaseStream.Position + next.length - next.headerLength));
                            }
                        }
                    }
                }
                movieIn.BaseStream.Seek(next.length - next.headerLength, SeekOrigin.Current);
            } while (movieIn.BaseStream.Position < endPosition);

            return(false);
        }
Пример #2
0
        private bool findContainer(byte[] name, BinaryReader movieIn, long endPosition)
        {
            do
            {
                var next = new atomlib.Container();
                next.ReadBoxHeader(movieIn);
                System.Console.WriteLine("fC - " + System.Text.Encoding.ASCII.GetString(next.name));
                if (next.CompareName(name))
                {
                    return(true);
                }
                movieIn.BaseStream.Seek(next.length - next.headerLength, SeekOrigin.Current);
            } while (movieIn.BaseStream.Position < endPosition);

            return(false);
        }
Пример #3
0
        public void ProcessMoov(BinaryReader movieIn, BinaryWriter movieOut)
        {
            byte[] trak = Encoding.ASCII.GetBytes(@"trak");

            long endPosition = movieIn.BaseStream.Position;

            var moov = new atomlib.Container();

            moov.ReadBoxHeader(movieIn);

            endPosition += moov.length;

            do
            {
                var next = new atomlib.Container();
                next.ReadBoxHeader(movieIn);
                System.Console.WriteLine("PM - " + System.Text.Encoding.ASCII.GetString(next.name));
                if (next.CompareName(trak))
                {
                    long startPosition = movieIn.BaseStream.Position;
                    bool foundCamm     = findCammBox(movieIn, movieIn.BaseStream.Position + next.length - next.headerLength);
                    movieIn.BaseStream.Seek(startPosition, SeekOrigin.Begin);
                    if (foundCamm)
                    {
                        // need write this one out bit by bit
                        next.CopyBox(movieIn, movieOut);
                    }
                    else
                    {
                        next.CopyBox(movieIn, movieOut);
                    }
                }
                else
                {
                    next.CopyBox(movieIn, movieOut);
                }
            } while (movieIn.BaseStream.Position < endPosition);
        }