locked
using MediaCapture StartRecordToStreamAsync()

    Question

  • Hi, I'm writing Augmented Reality App using SharpDX. I arrived to the moment when I'm able to render video on a texture; I can first record video from webcam using MediaCapture StartRecordToStorageFileAsync() then open it and place it on texture in DX. I encountered problem: when I want to avoid writing/reading from file(from obvious reasons) and use memoryStream instead - use MediaCapture StartRecordToStreamAsync(). I get empty screen. I had an idea, that it's caused by locking the stream when writing to it(disabling simultaneous reading/writing). I don't know if I'm right. Can anyone help me with this?

    Ps. I'm aware of MFT Drivers but I really want to avoid this.

    Tuesday, November 27, 2012 5:09 PM

All replies

  • I know I'm fetching an old thread, just thought we might be able to help each other ;)

    I'm having kind of the same problem. I want to do some live video manipulations, and I have the same problem when I from read or use the following stream.

    MediaCapture mediaCaptureMgr = new MediaCapture();
    await mediaCaptureMgr.InitializeAsync();

    VideoStream.Source = mediaCaptureMgr;
    await mediaCaptureMgr.StartPreviewAsync();

    IRandomAccessStream videostream = new InMemoryRandomAccessStream();
    await mediaCaptureMgr.StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Vga), videostream);

    After this, I try acces the stream by

    // Had some trouble with size, just wanted it to be big enough.
    var bArray = new byte[videostream.Size*2]; videostream.ReadAsync(bArray.AsBuffer(), (uint)videostream.Size, Windows.Storage.Streams.InputStreamOptions.ReadAhead); Stream s = videostream.AsStreamForRead(); byte[] glob = new byte[s.Length]; await s.ReadAsync(glob, 0, glob.Length);

    Turns out if I convert this picture into image through an extension to WriteableBitmap, it gives me as you, nothing. After debugging a bit, I realized the byte array glob is filled with zeroes. This could also be the answer to your problem!



    Saturday, December 29, 2012 7:35 PM