Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Im using a webcam to show live stream, capture images, record video etc using AForge library.
Each time I get a new frame, I assign it to a pictureBox to show the live stream and i have added a toolstrip for recording video when it is checked. so i did it in the same following method.

private void video_NewFrame( object sender, NewFrameEventArgs eventArgs)
{
// Assigning new frame to a picturebox
pictureBox1.Image = newFrame;

if(recordVideo.Checked)
{
writer.AddFrame(newFrame);
}
}

when the recordVideo toolstrip is checked. I open the avi file
writer.Open("test.avi", pictureBox1.Width, pictureBox1.Height);

and when it is unchecked i close the file.
writer.Close();

but when i start recording the video i get the following error:
InvalidOperationException - object is currently in use elsewhere.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900