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);
}
}