tags:

views:

5

answers:

0

Dear Friends In my WPF application, I have to capture video and need to save it as an .AVI file. I am using AForgeNet for this purpose.It work fine.But the video size is extremely large. How can I reduce the video size. Please help me. I am using this dll AForge.Video.VFW.dll

This is my module.

    private void MovieRecordFn()
    {
        Console.WriteLine("MovieRecordFn thread  started");
        Logger.Instance.LogInfo("Entering StateSimulation::MovieRecordFn");
        try
        {

            Rectangle screenSize = System.Windows.Forms.Screen.PrimaryScreen.Bounds;                
            int CaptureFrameWidth = DataStoreSingleTon.Instance.SimBorderWidth-500;
            int CaptureFrameHeight =DataStoreSingleTon.Instance.SimBorderHeight-250;

            Bitmap TargetFrameCaptured = new Bitmap(CaptureFrameWidth,CaptureFrameHeight);

            string ProjectPath = DataStoreSingleTon.Instance.ProjectFilePath;
            string ProjectName = DataStoreSingleTon.Instance.ProjectName;

            if (DataStoreSingleTon.Instance.IsAviRecording == true)
            {
                writer.FrameRate = Const.FPS_RATE_FOR_VIDEO_CAPTURE;
                string NameOfVideoFile = ProjectPath + "\\" + Const.SIMULATION_VIDEO_PATH + "\\" + Const.SIMULATION_VIDEO_PATH + ProjectName + DateTime.Now.Date.Day.ToString() + DateTime.Now.Date.Month.ToString() + DateTime.Now.Date.Year.ToString() + "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString() + "_" + DateTime.Now.Millisecond.ToString() + ".avi";
                DataStoreSingleTon.Instance.MarqueeMessage = Const.VIDEO_CAPTURE_LOCATION+" "+NameOfVideoFile;
                writer.Open(NameOfVideoFile,CaptureFrameWidth,CaptureFrameHeight);
            }

            while (DataStoreSingleTon.Instance.IsAviRecording == true)
            {
                // update image                    
                using (Graphics g = Graphics.FromImage(TargetFrameCaptured))
                {
                    int FromThisXPoint = DataStoreSingleTon.Instance.Capture_Pos_Left-10; 
                    int FromThisYPoint = DataStoreSingleTon.Instance.Capture_Pos_Top-10;
                    g.CopyFromScreen(FromThisXPoint,FromThisYPoint, 0, 0, new System.Drawing.Size(CaptureFrameWidth,CaptureFrameHeight));

                }
                // add the image as a new frame of video file
                if ((DataStoreSingleTon.Instance.IsAviRecording == true))
                {
                    writer.AddFrame(TargetFrameCaptured);
                    Thread.Sleep(100);
                }
                else
                {
                    continue;
                }
            }

            writer.Close();

           // UIControlHandler.Instance.ShowMessage(Const.VIDEO_CAPTURING_COMPLETED + ProjectPath + "\\" + Const.SIMULATION_VIDEO_PATH, enMsgType.Info);
        }
        catch (Exception ex)
        {
            Logger.Instance.LogError("Unknown exception in StateSimulation::MovieRecordFn :" + ex.Message.ToString());
        }
        finally
        {
            Logger.Instance.LogInfo("Exiting StateSimulation::MovieRecordFn");
        }

    }

Please help... Regards Nidhin