我用CaptureSource()
来记录就像这个主题的影片如何录制在Windows Phone的摄像头应用程序的视频 ,但我不能让录制的视频的缩略图。
Answer 1:
这里是解决方案:
[...]
// Add eventhandlers for captureSource.
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
captureSource.CaptureImageCompleted += captureSource_CaptureImageCompleted;
[...]
captureSource.Start();
captureSource.CaptureImageAsync();
[...]
void captureSource_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e)
{
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
System.Windows.Media.Imaging.WriteableBitmap wb = e.Result;
string fileName = "CameraMovie.jpg";
if (isoStore.FileExists(fileName))
isoStore.DeleteFile(fileName);
IsolatedStorageFileStream file = isoStore.CreateFile(fileName);
System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, file, wb.PixelWidth, wb.PixelHeight, 0, 85);
file.Close();
}
}
UPDATE:给用户采取的缩略图时,他想的可能性
添加点击事件viewfinderRectangle
<Rectangle
x:Name="viewfinderRectangle"
[...]
Tap="viewfinderRectangle_Tap" />
呼叫captureSource.CaptureImageAsync();
在点击事件
private void viewfinderRectangle_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
captureSource.CaptureImageAsync();
}
Answer 2:
你可以试试这个。 如果您正在使用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();
}
}
}
文章来源: How to get the thumbnail of a recorded video - windows phone 8?