问题描述
大家好,我正在使用Accord视频FFMPEG来捕获视频,但是我却遇到了这种异常,我是否可以知道为什么会发生这种异常以及如何克服这种情况
Bitmap region is already locked.,at System.Drawing.Bitmap.LockBits(Rectangle rect,ImageLockMode flags,PixelFormat format,BitmapData bitmapData)
at System.Drawing.Bitmap.LockBits(Rectangle rect,PixelFormat format)
at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(Bitmap frame,UInt32 frameIndex)
at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(Bitmap frame,TimeSpan timestamp)
at ProHance.PHProbeScreenCapture.VideoCapture.video_NewFrame(Object sender,NewFrameEventArgs eventArgs)
这是我将框架绑定到录像机的代码
Bitmap frame = eventArgs.Frame;
{
Graphics graphics = Graphics.FromImage(frame);
try
{
NativeMethods.CURSORINFO pci;
pci.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(NativeMethods.CURSORINFO));
if (NativeMethods.GetCursorInfo(out pci))
{
if (pci.flags == NativeMethods.CURSOR_SHOWING)
{
int x = pci.ptScreenPos.x - screenLeft;
int y = pci.ptScreenPos.y - screenTop;
Color c = Color.Yellow;
float width = 2;
int radius = 30;
if ((Control.MouseButtons & MouseButtons.Left) != 0 || (Control.MouseButtons & MouseButtons.Right) != 0)
{
c = Color.OrangeRed;
width = 4;
radius = 35;
}
Pen p = new Pen(c,width);
graphics.DrawEllipse(p,x - radius / 2,y - radius / 2,radius,radius);
NativeMethods.DrawIcon(graphics.GetHdc(),x,y,pci.hCursor);
graphics.ReleaseHdc();
}
}
this._writer.WriteVideoFrame(frame,(DateTime.Now - videoStartTime));
}
catch (Exception)
{
this._writer.WriteVideoFrame(eventArgs.Frame,(DateTime.Now - videoStartTime));
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)