Nick
Nick

Reputation: 1025

MediaCapture: Photos have odd color letterboxing on Windows Phone

I have some code to obtain the highest quality video encoding properties for my Lumia 1020 when taking photos. It is as follows,

 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();

This returns one of the only 1280 x 720 resolutions available to me. When I take the photo I get weird green lines each side. I've attached the photos, any idea why this happens and how to avoid it?

Excuse my messy face lol!

Subtype : Unknown Subtype : NV12

Upvotes: 3

Views: 186

Answers (2)

Mike
Mike

Reputation: 2260

On Windows Phones, you'll find three separate MediaStreamTypes: VideoPreview, Photo and VideoRecord. Think of these as three separate streams coming from the camera, for the viewfinder, for photographs, and for recording videos, respectively. The fact that these are separate streams means you can set the resolution (a.k.a. MediaStreamProperties) on each stream separately:

  • You can run the preview at screen resolution
  • You can capture photos at 20 MP
  • You can record video at 1080p

That way you don't run the device at 20 MP all the time.

Now, even though these are separate pins, there are some limitations, and you just ran into one: The aspect ratio for the capture streams (Photo, VideoRecord) needs to match the aspect ratio for the VideoPreview, otherwise you can get odd artifacts. This gives you two options:

  1. Have two separate capture modes: Photo and Video. When switching between these modes, make sure to set a resolution on the preview that matches the capture aspect ratio you want to use.
  2. Have an aspect ratio chooser as the top-level decision. This means you first decide whether you want 16:9 or 4:3 as your capture resolution, then you set the preview based on that, and then you only allow capturing photos or video in the same aspect ratio. The benefit of this is that you don't need to switch 'modes' to get a different kind of capture.

Upvotes: 3

Nick
Nick

Reputation: 1025

Typical, just tried something and resolved the issue, I changed the type of encoding props to photo rather than 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();

and

await cMCeCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo,

Upvotes: 0

Related Questions