question

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT asked ·

[UWP][VB]Limiting Stream Size For MediaCapture

Source Link: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/2aa719db-7aa2-4b2f-bc39-b8fca5fda397/uwpvblimiting-stream-size-for-mediacapture?forum=wpdevelop

I have a MediaCapture from which I want to capture a stream, as follows:

 Await Me.cardcapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreatePng(), stream)


This works fine, except that the stream is larger than I want (I want to keep it below 2MB). I have looked at the following page:

https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/set-media-encoding-properties

But I wasn't quite sure what to do. I also tried the following page:

https://docs.microsoft.com/en-us/uwp/api/windows.media.capture.mediacapture.preparelowlagrecordtostreamasync

But I couldn't get it to work. All I need is to get a smaller stream, can anybody help me? Thanks.

uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered ·

Hello,

Welcome to Microsoft Q&A!

First, if you want to get smaller steam from CapturePhotoToStreamAsync, you could try to lower the steam resolution before you capture the photo using VideoDeviceController.SetMediaStreamPropertiesAsync() Method.

Here is the test I tried on my side: alt text

alt text From the screenshot, you could see that the size of the steam is smaller in the second test.

For more information, you could refer to Scenario 2 of the official sample here: CameraResolution.


123.png (429.3 KiB)
234.png (428.9 KiB)
· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.