如何更改Windows Phone的默认视频拍摄分辨率8,8.1 [英] how to change the default video capture resolution in windows phone 8,8.1

查看:218
本文介绍了如何更改Windows Phone的默认视频拍摄分辨率8,8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个应用程序,这将使用户的选择来选择视频录制分辨率大小(如全高清1920×1080或VGA-640×480等)

I want build an app that will give users options to choose the resolution size of video recording (such as full HD-1920x1080 or vga-640x480 etc.)

我使用下面的代码,但是当我在模拟器720p的运行它,它表明这是在其他部分,即摄像头不支持此消息。 (当我改变了价值800450,640,480相机开始正常工作)

I am using the code below but when I run this on 720p emulator, it shows the message which is in else part i.e. camera not support this. (when I change the value 800,450 , to 640 ,480 camera start working normally)

try
           {
              //string deviceName = DeviceStatus.DeviceName;
               //var deviceName = DeviceStatus.DeviceName;
               //if (deviceName.Contains("RM-885"))
               //{
                   Windows.Foundation.Size initialResolution = new Windows.Foundation.Size(800, 450);
                   Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(800, 450);
                   Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(800, 450);
                   if (AudioVideoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
                   {
                       pops = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, initialResolution);
                       await pops.SetPreviewResolutionAsync(previewResolution);
                       await pops.SetCaptureResolutionAsync(captureResolution);    


                   }
               }
          // }

           catch (Exception p) { Debug.WriteLine(p.Message); }

            try
            {
                if(pops != null)
                {


                    // create the videobrush for the viewfinder
                    videoRecordBrush = new VideoBrush();
                    videoRecordBrush.SetSource(pops);
                    // display the viewfinder image 
                    viewfinderRectangle.Fill = videoRecordBrush;
                    //shows available resolution message 
                    MessageBox.Show("statrt recording ");
                    MessageBox.Show(pops.PreviewResolution.ToString());
                    MessageBox.Show(pops.CaptureResolution.ToString());


                }
                else
                {
                    MessageBox.Show("camera not support this ");
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("exception" + ex);
            }
        }



是改变在视频模式下的分辨率这个正确的代码?或者还有什么其他的方法?

Is this right code to change the resolution in video mode? or is there any other method?

推荐答案

在的Windows Phone 8.1,U可以改变的宽高比的两者的视频预览拍摄的照片按改变的 MediaCapture.VideoDeviceController 的设置。

In Windows Phone 8.1, u can change the aspect ratio of both video preview and captured photo by changing the MediaCapture.VideoDeviceController setting.

视频预览相机可以从屏幕上看到你实际拍摄照片前视图。是它是视频预览的宽高比并捕获照片必不可少同样为避免怪异线和放大器;黑条在拍摄的照片。换句话说,它是确保捕获是完全一样的,你在屏幕上看到预览的照片。

Video preview is the view of camera you can see from your screen before you actually capture a photo. It is essential for the aspect ratio of video preview and captured photo to be the same to avoid weird lines & black bars in the captured photo. In other words, it is to ensure the photo captured to be exactly the same as the preview you see on the screen.

首先,你可以检查所有可用的分辨率您的Windows Phone 8.1。在下面的代码,我将演示如何检查可用的分辨率作为视频预览和放大器;拍摄的照片。高度和放大器; WIDTH返回是为您的手机,例如可用的分辨率I = 0,高= 1080,宽度= 1920(192​​0×1080)。请在调试的高度和放大器;宽度线检查不同分辨率

First, you can check all the available resolutions in your Windows Phone 8.1. In the following code, I demonstrate how to check resolutions available for video preview & captured photo. The height&width returned is the resolutions available for your phone, e.g at i=0, height=1080, width=1920 (1920x1080). Please debug at the height&width line to check for different resolution.

MediaCapture mediacapture = new MediaCapture();
await mediacapture.InitializeAsync(new MediaCaptureInitializationSettings{});
var previewResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
var photoResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);

        VideoEncodingProperties allResolutionsAvailable;
        uint height, width;
  //use debugger at the following line to check height & width for video preview resolution
        for (int i = 0; i < previewResolution.Count; i++)
        {
            allResolutionsAvailable = previewResolution[i] as VideoEncodingProperties;
            height = allResolutionsAvailable.Height;
            width = allResolutionsAvailable.Width;
        }
  //use debugger at the following line to check height & width for captured photo resolution
        for (int i = 0; i < photoResolution.Count; i++)
        {
            allResolutionsAvailable = photoResolution[i] as VideoEncodingProperties;
            height = allResolutionsAvailable.Height;
            width = allResolutionsAvailable.Width;
        }

这是检查所有可用的分辨率后的高度的和宽度的上述参数,可以选择特定的分辨率要使用.ElementAt(int)方法,例如: .ElementAt(0)

After checking all the available resolutions from the height and width parameter above, you can select the particular resolutions you want by using .ElementAt(int) method, e.g. .ElementAt(0)

var selectedPreviewResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).ElementAt(1);
var selectedPhotoResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).ElementAt(1);

await mediacapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, selectedPreviewResolution);
await mediacapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, selectedPhotoResolution);

//in .xaml <CaptureElement Name="viewfinder"/>
viewfinder.Source = mediacapture;
//to set video preview upright
mediacapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
await mediacapture.StartPreviewAsync();



设置.ElementAt(i)在视频预览和放大器;在相同的纵横比单独捕获照片。
以下可用于诺基亚Lumia 1520的分辨率。

Set .ElementAt(i) for Video Preview & Captured Photo separately at the same aspect ratio. Below are the resolutions available for Nokia Lumia 1520.

视频预览


  • 我.....高* width..aspect比

  • 0 ..... 1080 * 1920 .... 16:9

  • 1 ...... 720×1280 ..... 16:9

  • 2 ...... 450 * 800 ....... 16:9

  • 3 .... 1080 * 1440 ...... 4:3

  • 4 ...... 768 * 1024 ...... 4:3

  • 5 ...... 480 * 640 ........ 4:3

  • i.....height*width..aspect ratio
  • 0.....1080*1920....16:9
  • 1......720*1280.....16:9
  • 2......450*800.......16:9
  • 3....1080*1440......4:3
  • 4......768*1024......4:3
  • 5......480*640........4:3

拍摄的照片


  • 我....高* width..aspect比

  • 0 .... 3024 * 4992 ....... 4:3

  • 1 ..... 1936年* 2592 ... 162:121

  • 2 ..... 1536 * 2048 ....... 4: 3

  • 3 ...... 480 * 640 .......... 4:3

  • 4 ... ..3024 * 5376 ..... 16:9

  • 5 ..... 1728 * 3072 ..... 16:9

  • 6 ..... 1456 * 2592 ... 162:91

  • i.... height*width..aspect ratio
  • 0.... 3024*4992.......4:3
  • 1.....1936*2592...162:121
  • 2.....1536*2048.......4:3
  • 3......480*640..........4:3
  • 4.....3024*5376.....16:9
  • 5.....1728*3072.....16:9
  • 6.....1456*2592...162:91

最后,如果你想使用最大分辨率同时适用于视频预览和放大器; 3宽高比
VAR:4捕捉照片,可以使用下面的代码而不是

Lastly, if you want to use the maximum resolution available for both Video Preview & Captured Photo, you can use the following code instead.

//maximum resolution for 4:3 aspect ratio 
 var maxPhotoResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Height > (i2 as VideoEncodingProperties).Height ? i1 : i2);
 var maxPreviewResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Height > (i2 as VideoEncodingProperties).Height ? i1 : i2);

//maximum resolution for 16:9 aspect ratio 
 var maxPhotoResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);
 var maxPreviewResolution = mediacapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Aggregate((i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);

await mediacapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, maxPhotoResolution);
await mediacapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, maxPreviewResolution);

这篇关于如何更改Windows Phone的默认视频拍摄分辨率8,8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆