2013-06-18 71 views
8

我試圖在Windows Phone 8(具體而言,480x480)中以特定分辨率捕獲MP4視頻。我知道我不能使用預設以外的尺寸,而480x480不是預設。如何轉換捕獲的視頻(如640x480)並裁剪頂部和底部以使其達到480x480?歡迎任何免費或開源庫(在Windows Phone上運行)。請不要回答諸如「使用外部服務器」等答案,我需要一個設備上解決方案。在Windows Phone 8中以非標準尺寸錄製視頻(或轉換後)Windows Phone 8

回答

1

使用Windows.Phone.Media.Capture API和AudioVideoCaptureDevice.OpenAsync的AudioVideoCaptureDevice

第二個參數 - 見this link - 是分辨率。你可以使用AudioVideoCaptureDevice.GetAvailableCaptureResolutions(傳感器)

編輯得到的決議:要設置自定義分辨率嘗試AudioVideoCaptureDevice.SetCaptureResolutionAsync

編輯2:你可以嘗試像下面轉換錄製的視頻的內容:(找不到在哪裏我得到了來自SOZ創作的代碼!)

StorageFolder isoStore = await ApplicationData.Current.LocalFolder.GetFolderAsync("Shared"); 
     var file = await isoStore.CreateFileAsync("foos1.wmv", CreationCollisionOption.ReplaceExisting); 
     using (var s = await file.OpenAsync(FileAccessMode.ReadWrite)) 
     { 
      Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480); 
      avDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, 
       AudioVideoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back).Last()); 

      VideoBrush videoRecorderBrush = new VideoBrush(); 
      videoRecorderBrush.SetSource(avDevice); 

      viewfinderRectangle.Fill = videoRecorderBrush; 

      await avDevice.StartRecordingToStreamAsync(s); 

      Thread.Sleep(30000); 

      await avDevice.StopRecordingAsync(); 
     } 


     new MediaPlayerLauncher() 
     { 
      Media = new Uri(file.Path, UriKind.Relative), 
     }.Show(); 
+0

'AudioVideoCaptureDevice.GetAvailableCaptureResolutions(傳感器)'不含有不期望的分辨率(比如我需要192x144) – CAMOBAP

+0

見編輯,並期待在使用SetCaptureResolutionAsync –

+0

我已經使用'GetAvailableCa ptureResolutions(CameraSensorLocation.Back).Last()',它返回640x480,但我需要'192x144' – CAMOBAP