Following this example i note that the resolution of the video is 640*480. The code works perfect. My webcam is a 1080p model. How do i get the Raspberry PI to save video at 1080p?
Here is the camera initialization code directly from the sample,aswell as the code to record video. I cannot find any location where the resolution is set.
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;
}
}
Take a look at "VideoDeviceController.GetAvailableMediaStreamProperties" and "VideoDeviceController.SetMediaStreamPropertiesAsync" toget the available resolutions and set the resolution of the video capture device.
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