Hi,
I'm using C#.net 3.0. I have use the frameGrabber class to grab the frames from the video file and to convert the frames into bitmap format.The code is giving error in the "foreach (FrameGrabber.Frame f in fg)line of the code" highlighting "in" giving error---"InvalidCastException was unhandled by user"(Unable to cast COM object of type'DirectShowLib.DES.MediaDet' to interface type 'DirectShowLib.DES.IMediaDet'.This operation failed because the QueryInterface call on the COM component for the interface with IID '{65BD0710-24D2-4FF7-9324-ED2E5D3ABAFA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).).I use this background worker so that I can stop the extraction of frame in middle of execution,but if i don't use this Background worker the code is running properly.
private void button43_Click(object sender, EventArgs e)//Extract Button
{
backgroundWorker1.RunWorkerAsync();
}
private void button44_Click(object sender, EventArgs e)//Stop Button
{
backgroundWorker1.CancelAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
string outPath = txtExtBitmap.Text;
System.IO.Directory.CreateDirectory(outPath);
if (fg != null)
{
foreach (FrameGrabber.Frame f in fg)//error in this line highlighting "in"
{
using (f)
{
picBoxFrame.Image = (Bitmap)f.Image.Clone();
f.Image.Save(System.IO.Path.Combine(outPath, "frame" + f.FrameIndex + ".bmp"), System.Drawing.Imaging.ImageFormat.Bmp);
//Application.DoEvents();
}
if (fg == null)
{
return;
}
}
}
if (backgroundWorker1.CancellationPending)
{
e.Cancel = true;
return;
}
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Cancelled)
{
MessageBox.Show("Operation Cancelled");
}
else
{
MessageBox.Show("OperationCompleted");
}
}