Beispiel #1
0
        public void CaptureVideo()
        {
            b = new Bitmap(ScreenWidth, ScreenHeight);
            g = Graphics.FromImage(b);
            g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);


            //auto set options for video recording
            //(description for each option availible at http://msdn.microsoft.com/en-us/library/windows/desktop/dd756832(v=vs.85).aspx)
            Avi.AVICOMPRESSOPTIONS aviOptions = new Avi.AVICOMPRESSOPTIONS();
            aviOptions.fccType = (uint)Avi.streamtypeVIDEO;
            //codec to use MSVC = Microsoft Video 1
            aviOptions.fccHandler = (uint)Avi.mmioStringToFOURCC("MSVC", 0);
            //quality option go from 0-10000
            aviOptions.dwQuality = 5000;

            //change aviOptions to "true" to enable the popup window asking for codec options eg. aviStream = aviManager.AddVideoStream(true, 4, b);
            aviStream = aviManager.AddVideoStream(aviOptions, 4, b);

            Bitmap tempBmp;

            while (!pause)
            {
                tempBmp = new Bitmap(ScreenWidth, ScreenHeight);
                g       = Graphics.FromImage(tempBmp);
                g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
                g.FillEllipse(fillBrush, currentPoint.X, currentPoint.Y, 10, 10);
                g.FillRectangle(new SolidBrush(Color.Black), ScreenWidth - 100, ScreenHeight - 30, 100, 30);
                g.DrawString(elapsedTime, new Font("Arial", 12), new SolidBrush(Color.White), new PointF(ScreenWidth - 95, ScreenHeight - 25));

                if (tempBmp != null)
                {
                    try
                    {
                        aviStream.AddFrame(tempBmp);
                    }
                    catch
                    {
                        Bitmap bmp2 = tempBmp;
                        tempBmp.Dispose();
                        tempBmp = new Bitmap((Image)bmp2);
                        aviStream.AddFrame(tempBmp);
                    }
                }
                tempBmp.Dispose();
                Thread.Sleep(50);
            }
            aviManager.Close();
        }
Beispiel #2
0
        private Avi.AVICOMPRESSOPTIONS createCompressedOptions()
        {
            Avi.AVICOMPRESSOPTIONS opts = new Avi.AVICOMPRESSOPTIONS();
            opts.fccType           = (UInt32)Avi.mmioStringToFOURCC("vids", 0);
            opts.fccHandler        = (UInt32)Avi.mmioStringToFOURCC("CVID", 0);
            opts.dwKeyFrameEvery   = 0;
            opts.dwQuality         = 0;                         // 0 .. 10000
            opts.dwFlags           = Avi.AVICOMPRESSF_DATARATE; // AVICOMRPESSF_KEYFRAMES = 4
            opts.dwBytesPerSecond  = 0;
            opts.lpFormat          = new IntPtr(0);
            opts.cbFormat          = 0;
            opts.lpParms           = new IntPtr(0);
            opts.cbParms           = 0;
            opts.dwInterleaveEvery = 0;

            return(opts);
        }