AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

recorded video resolution is off

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

recorded video resolution is off

Postby btb4198 » Sun Nov 17, 2019 2:24 am

I am using Aforge to connect to my webcam and then record a video. but the record video resolution is not a good as the livefeed.
here is my code :

Code: Select all
void recordLiveVideo()
        {

            SaveFileDialog dialog = new SaveFileDialog();
               dialog.FileName = "Video1";
            dialog.DefaultExt = ".avi";
            dialog.AddExtension = true;
            var dialogresult = dialog.ShowDialog();
            if (dialogresult != DialogResult.OK)
            {
                record.Text = "recording...";
                return;
            }
           
            int h = videoSource.VideoCapabilities[0].FrameSize.Height;
            int w = videoSource.VideoCapabilities[0].FrameSize.Width;
           // int frameRate = videoSource.VideoCapabilities[0].AverageFrameRate;
            int frameRate = videoSource.VideoResolution.FrameRate;

            int bitrate = videoSource.VideoCapabilities[0].BitCount;

            FileWriter.Open(dialog.FileName, w, h, frameRate, VideoCodec.MPEG4, bitrate);

            _recording = true;
        }


here is how I set my videoSource:

Code: Select all
void IR_Connect()
        {
             VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();

                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    // create video source
                    videoSource = form.VideoDevice;
                    // open it
                    OpenVideoSource(videoSource);
                connect = true;
                     ConnectBln.Text  = "Disconnect";
                }

            Live_FeedBTN.Enabled = true;
        }


Also if I pick Video resolution : 1280 x 720, then click recorded have over have the video do not show up in the recorded video.

here is code for my write:
Code: Select all
  private void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
        {
           float f = motiondetector.ProcessFrame(image);
            image1 = image;


            AppendFloatPointTxt(Convert.ToString(f));
            if (f > 0.01)
            {
                //captureImage(image);
               
               
            }

            if (_recording)
            {
                //   _writer.WriteVideoFrame(image);
                FileWriter.WriteVideoFrame(image);
            }
        }
btb4198
 
Posts: 33
Joined: Fri May 18, 2018 2:31 am

Re: recorded video resolution is off

Postby andrew.kirillov » Sun Nov 17, 2019 4:44 pm

Did you try increasing bit rate value ?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework

cron