使用 1080p 网络摄像头在 windows IOT 上录制

Record on windows IOT from webcam in 1080p

根据 this 示例,我注意到视频的分辨率为 640*480。该代码完美无缺。我的网络摄像头是 1080p 型号。 我如何获得 Raspberry PI 以保存 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;                
        }
    }

查看 "VideoDeviceController.GetAvailableMediaStreamProperties" 和 "VideoDeviceController.SetMediaStreamPropertiesAsync" 以获取可用分辨率并设置视频捕获设备的分辨率。

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