예제 #1
0
        public bool playFile(string filename)
        {
            //using (Stream fin = File.OpenRead(filename))
            using (Stream fin = new MemoryStream(File.ReadAllBytes(filename)))
                using (FrameDecoder FrameDecoder = new FrameDecoder(fin))
                {
                    try
                    {
                        while (true)
                        {
                            var picture = FrameDecoder.DecodeFrame();

                            var Width  = picture.imageWidthWOEdge;
                            var Height = picture.imageHeightWOEdge;

                            if (frame.ClientSize.Width < Width || frame.ClientSize.Height < Height)
                            {
                                frame.Invoke((Action)(() =>
                                {
                                    frame.ClientSize = new Size(Width, Height);
                                    CenterForm(frame);
                                }));
                            }
                            frame.CreateGraphics().DrawImage(picture.ToImageWOEdges(Width, Height), Point.Empty);
                        }
                    }
                    catch (EndOfStreamException)
                    {
                    }
                }

            Console.WriteLine("Stop playing video.");

            return(true);
        }
예제 #2
0
        private void TestItem(string fixtureName, string videoName)
        {
            var RemotePath = BaseUrl + videoName;
            var LocalPath = Directory.GetCurrentDirectory() + "/../../Cache/" + videoName;
            try { Directory.CreateDirectory(Path.GetDirectoryName(LocalPath)); } catch { }
            if (!File.Exists(LocalPath)) new WebClient().DownloadFile(RemotePath, LocalPath);

            var FrameDecoder = new FrameDecoder(File.OpenRead(LocalPath));
            var Index = 0;
            while (FrameDecoder.HasMorePackets)
            {
                //var Packet = FrameDecoder._ReadPacket();
                //Console.WriteLine("{0}: {1}", Index, FrameCrc.GetFrameLine(Packet));
                var Frame = FrameDecoder.DecodeFrame();
                var Image = FrameUtils.imageFromFrame(Frame);
                Console.WriteLine("{0}: {1}, {2}, {3}", Index, Frame.pkt_dts, Frame.pkt_pts, Frame.imageWidthWOEdge * Frame.imageHeightWOEdge);
                Index++;
            }
        }
예제 #3
0
파일: H264Player.cs 프로젝트: pansk/cscodec
        public bool playFile(string filename)
        {
            //using (Stream fin = File.OpenRead(filename))
            using (Stream fin = new MemoryStream(File.ReadAllBytes(filename)))
            using (FrameDecoder FrameDecoder = new FrameDecoder(fin))
            {
                try
                {
                    while (true)
                    {
                        var picture = FrameDecoder.DecodeFrame();

                        var Width = picture.imageWidthWOEdge;
                        var Height = picture.imageHeightWOEdge;

                        if (frame.ClientSize.Width < Width || frame.ClientSize.Height < Height)
                        {
                            frame.Invoke((Action)(() =>
                            {
                                frame.ClientSize = new Size(Width, Height);
                                CenterForm(frame);
                            }));
                        }
                        frame.CreateGraphics().DrawImage(picture.ToImageWOEdges(Width, Height), Point.Empty);
                    }
                }
                catch (EndOfStreamException)
                {
                }
            }

            Console.WriteLine("Stop playing video.");

            return true;
        }