0

Следуя примеру this, обратите внимание, что разрешение видео составляет 640 * 480. Код работает отлично. Моя веб-камера - модель 1080p. Как получить малиновый PI для сохранения видео на 1080p?Запись на окнах IOT с веб-камеры в 1080p

Вот код инициализации камеры непосредственно из образца, а также код для записи видео. Я не могу найти места, где установлено разрешение.

private async void initVideo_Click(object sender, RoutedEventArgs e) 
    { 
     // Disable all buttons until initialization completes 

     SetInitButtonVisibility(Action.DISABLE); 
     SetVideoButtonVisibility(Action.DISABLE); 
     SetAudioButtonVisibility(Action.DISABLE); 

     try 
     { 
      if (mediaCapture != null) 
      { 
       // Cleanup MediaCapture object 
       if (isPreviewing) 
       { 
        await mediaCapture.StopPreviewAsync(); 
        captureImage.Source = null; 
        playbackElement.Source = null; 
        isPreviewing = false; 
       } 
       if (isRecording) 
       { 
        await mediaCapture.StopRecordAsync(); 
        isRecording = false; 
        recordVideo.Content = "Start Video Record"; 
        recordAudio.Content = "Start Audio Record"; 
       } 
       mediaCapture.Dispose(); 
       mediaCapture = null; 
      } 

      status.Text = "Initializing camera to capture audio and video..."; 
      // Use default initialization 
      mediaCapture = new MediaCapture(); 
      await mediaCapture.InitializeAsync();     

      // Set callbacks for failure and recording limit exceeded 
      status.Text = "Device successfully initialized for video recording!"; 
      mediaCapture.Failed += new MediaCaptureFailedEventHandler(mediaCapture_Failed); 
      mediaCapture.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(mediaCapture_RecordLimitExceeded); 

      // Start Preview     
      previewElement.Source = mediaCapture; 
      await mediaCapture.StartPreviewAsync(); 
      isPreviewing = true; 
      status.Text = "Camera preview succeeded"; 

      // Enable buttons for video and photo capture 
      SetVideoButtonVisibility(Action.ENABLE); 

      // Enable Audio Only Init button, leave the video init button disabled 
      audio_init.IsEnabled = true; 
     } 
     catch (Exception ex) 
     { 
      status.Text = "Unable to initialize camera for audio/video mode: " + ex.Message;    
     } 
    } 



    private async void recordVideo_Click(object sender, RoutedEventArgs e) 
    { 
     try 
     { 
      takePhoto.IsEnabled = false; 
      recordVideo.IsEnabled = false; 
      playbackElement.Source = null; 

      if (recordVideo.Content.ToString() == "Start Video Record") 
      { 
       takePhoto.IsEnabled = false; 
       status.Text = "Initialize video recording"; 
       String fileName; 
       fileName = VIDEO_FILE_NAME; 

       recordStorageFile = await Windows.Storage.KnownFolders.VideosLibrary.CreateFileAsync(fileName, Windows.Storage.CreationCollisionOption.GenerateUniqueName); 

       status.Text = "Video storage file preparation successful"; 

       MediaEncodingProfile recordProfile = null; 
       recordProfile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Auto); 

       await mediaCapture.StartRecordToStorageFileAsync(recordProfile, recordStorageFile); 
       recordVideo.IsEnabled = true; 
       recordVideo.Content = "Stop Video Record"; 
       isRecording = true; 
       status.Text = "Video recording in progress... press \'Stop Video Record\' to stop"; 
      } 
      else 
      { 
       takePhoto.IsEnabled = true; 
       status.Text = "Stopping video recording..."; 
       await mediaCapture.StopRecordAsync(); 
       isRecording = false; 

       var stream = await recordStorageFile.OpenReadAsync(); 
       playbackElement.AutoPlay = true; 
       playbackElement.SetSource(stream, recordStorageFile.FileType); 
       playbackElement.Play(); 
       status.Text = "Playing recorded video" + recordStorageFile.Path; 
       recordVideo.Content = "Start Video Record"; 
      } 
     } 
     catch (Exception ex) 
     { 
      if (ex is System.UnauthorizedAccessException) 
      { 
       status.Text = "Unable to play recorded video; video recorded successfully to: " + recordStorageFile.Path; 
       recordVideo.Content = "Start Video Record"; 
      } 
      else 
      { 
       status.Text = ex.Message; 
       Cleanup(); 
      }     
     } 
     finally 
     {     
      recordVideo.IsEnabled = true;     
     } 
    } 

ответ

2

Посмотрите на «VideoDeviceController.GetAvailableMediaStreamProperties» и «VideoDeviceController.SetMediaStreamPropertiesAsync» toget доступных разрешений и установить разрешение устройства захвата видео.

http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.videodevicecontroller.getavailablemediastreamproperties.aspx http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.videodevicecontroller.setmediastreampropertiesasync.aspx

Смежные вопросы