我使用 AudioVideoCapture 设备录制视频,但无法获取录制视频的缩略图。请帮我!
问问题
676 次
1 回答
0
你可以试试这个。如果您使用的是 AudioVideoCaptureDevice api。在每帧捕获后进行以下事件(预览缩略图)调用。您可以选择任何您需要的框架。作为第一个。
private AudioVideoCaptureDevice VideoRecordingDevice;
VideoRecordingDevice.PreviewFrameAvailable += previewThumbnail;
bool DisablePreviewFrame = false;
private void previewThumbnail(ICameraCaptureDevice a, object b)
{
if (!DisablePreviewFrame)
{
DisablePreviewFrame = true;
int frameWidth = (int)VideoRecordingDevice.PreviewResolution.Width;
int frameHeight = (int)VideoRecordingDevice.PreviewResolution.Height;
}
int[] buf = new int[frameWidth * frameHeight];
VideoRecordingDevice.GetPreviewBufferArgb(buf);
using (IsolatedStorageFile isoStoreFile = IsolatedStorageFile.GetUserStoreForApplication())
{
var fileName = "temp.jpg";
if (isoStoreFile.FileExists(fileName))
isoStoreFile.DeleteFile(fileName);
using (IsolatedStorageFileStream isostream = isoStoreFile.CreateFile(fileName))
{
WriteableBitmap wb = new WriteableBitmap(frameWidth, frameWidth);
Array.Copy(buf, wb.Pixels, buf.Length);
wb.SaveJpeg(isostream, 120, 120, 0, 60);
isostream.Close();
}
}
}
于 2015-06-08T05:18:22.027 回答