2013-08-02 60 views
0

我正嘗試在Windows Phone 8中創建一個視頻採集應用程序商店視頻文件和縮略圖。我從以下鏈接獲得了一些提示: How to get the thumbnail of a recorded video - windows phone 8?。 但結果很煩人。我認爲這個功能存在一些問題。在Windows Phone 8中使用「縮略圖」圖像記錄視頻文件8

void captureSource_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e) 
     { 
      using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       WriteableBitmap wb = e.Result; 
       string fileName = "CameraMovie.jpg"; 
       if (isoStore.FileExists(fileName)) 
        isoStore.DeleteFile(fileName); 
       IsolatedStorageFileStream file = isoStore.CreateFile(fileName); 
       Extensions.SaveJpeg(wb, file, wb.PixelWidth, wb.PixelHeight, 0, 85); 
       file.Close(); 

       captureSource.Stop(); 
       fileSink.CaptureSource = null; 
       fileSink.IsolatedStorageFileName = null; 
      } 
     } 

e.Result具有it.while我其綁定到的圖像控制某些無效數據它顯示了一些惱人圖像。 任何人都請幫助我。

回答

0

[編輯]添加一些解釋。

正在錄製的視頻的快照可以在錄製視頻的任何時候獲得。獲取預覽緩衝區成Argb像素並將其應用於可寫位圖。

當您必須顯示視頻時,請在屏幕截圖中添加一個疊加層,並在其上添加一個光面播放按鈕。

var videoWritableBitmap = new WriteableBitmap((int)[AudioVideoDevice].PreviewResolution.Width, (int)[AudioVideoDevice].PreviewResolution.Height); 

var argbPixels = new int[(int)[AudioVideoDevice].PreviewResolution.Width * (int)[AudioVideoDevice].PreviewResolution.Height]; 

[AudioVideoDevice].GetPreviewBufferArgb(argbPixels); 

argbPixels.CopyTo(videoWritableBitmap.Pixels, 0); 

var videoThumbNailFile = await[localFolder].OpenStreamForWriteAsync([ThumbNailImageName], CreationCollisionOption.ReplaceExisting); 

videoWritableBitmap.SaveJpeg(videoThumbNailFile, videoWritableBitmap.PixelWidth, videoWritableBitmap.PixelHeight, 0, 100); 
+0

請在您的回答中添加說明 – SSP

相關問題