MediaCapture:照片在Windows Phone

时间:2015-05-23 09:26:30

标签: c# windows-phone win-universal-app windows-10

我有一些代码可以在拍照时为我的Lumia 1020获得最高质量的视频编码属性。如下,

 IEnumerable<VideoEncodingProperties> pIEeAllRes = cMCeCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Select(x => x as VideoEncodingProperties);
 VideoEncodingProperties pVEPBestRes = pIEeAllRes.OrderByDescending(x => x.Width * x.Height).ThenByDescending(x => x.FrameRate.Numerator / (double)x.FrameRate.Denominator).FirstOrDefault();

这将返回我可用的唯一1280 x 720分辨率之一。当我拍照时,每侧都会出现奇怪的绿线。我附上照片,知道为什么会这样,以及如何避免它?

请原谅我凌乱的脸lol!

Subtype : Unknown Subtype : NV12

2 个答案:

答案 0 :(得分:3)

在Windows手机上,您会找到三个单独的MediaStreamTypesVideoPreviewPhotoVideoRecord。可以将这些视为来自相机,取景器,照片和录制视频的三个独立流。这些是独立流的事实意味着您可以分别在每个流上设置分辨率(a.k.a. MediaStreamProperties):

  • 您可以按屏幕分辨率运行预览
  • 您可以以20 MP
  • 拍摄照片
  • 您可以以1080p
  • 录制视频

这样你就不会一直以20 MP的速度运行设备。

现在,即使这些是单独的引脚, 有一些限制,你刚刚碰到一个:捕获流的长宽比(Photo,VideoRecord)需要匹配VideoPreview的宽高比,否则你可能会得到奇怪的神器。这为您提供了两个选项:

  1. 有两种不同的捕捉模式:照片和视频。在这些模式之间切换时,请确保在预览上设置与您要使用的捕获宽高比相匹配的分辨率。
  2. 将宽高比选择器作为顶级决策。这意味着您首先要确定是否需要16:9或4:3作为捕获分辨率,然后根据该设置设置预览,然后您只允许以相同的宽高比捕获照片或视频。这样做的好处是您无需切换“模式”即可获得不同类型的捕获。

答案 1 :(得分:0)

典型的,只是尝试了一些并解决了问题,我将编码道具的类型改为照片而不是videopreview,

        IEnumerable<VideoEncodingProperties> pIEeAllRes = cMCeCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Select(x => x as VideoEncodingProperties);
        VideoEncodingProperties pVEPBestRes = pIEeAllRes.OrderByDescending(x => x.Width * x.Height).ThenByDescending(x => x.FrameRate.Numerator / (double)x.FrameRate.Denominator).FirstOrDefault();

await cMCeCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo,