locked
Audio/ Video capturing In Windows 8 Metro App

    Question

  • I am working On Audio/Video capturing from a Web Camera and this is targeted On Windows 8 Metro Style Not on Desktop Mode.

    I planning to Write a Library for this So that any application can use this library to Stream Video.

    Windows 8 provides Direct X and Win RT for metro mode of Windows 8. I am bit confused which one to use it for this.

    Is  Win RT Alone is Sufficient for Detecting Camera and Capturing Audio/Video ?? Does Direct X Involvement is required here? 


    • Edited by chris_vr Tuesday, November 01, 2011 7:56 AM Spelling mistake
    Tuesday, November 01, 2011 7:55 AM

Answers

  • Btw, here is a code sample in C++:

    http://code.msdn.microsoft.com/Camera-Capture-UI-Sample-0b550324

    In order to answer your question, I really need to understand your scenarios better.  If you are going to do something computationally intensive, then C++ may be better.  The point is that feel free to use the language/technology in which you are most comfortable.

    Thanks

    Raman


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Thursday, November 03, 2011 12:59 AM

All replies

  • WinRT does the job for you.  Look at this sample:

    http://code.msdn.microsoft.com/Media-Capture-Sample-adf87622

     

    Raman

    Tuesday, November 01, 2011 5:03 PM
  • How about a C++ sample in a "Building Metro style apps with C++  " forum ?

    Tuesday, November 01, 2011 5:15 PM
  • The great thing about WinRT is that it can be used by any language.  It's pretty easy to create a C++ equivalent of that JS sample.

    So basically you have two options:

    • Use Windows.Media.Capture.CameraCaptureUI API:  Windows has provided a pre-built UI to capture images/video etc. from the camera. JS/C# Sample here.
    • Use Windows.Media.Capture.MediaCapture API:  You can create your own UI and still capture media from any kind of sources.  JS Sample here.
    I am providing below C++ representation of the first one.  Hopefully that should give an idea.
    void WinRTComponent::CapturePhoto()
    {
    	auto dialog = ref new Windows::Media::Capture::CameraCaptureUI();
    	Windows::Foundation::Size aspectRatio;
    	aspectRatio.Width = 16;
    	aspectRatio.Height = 9;
    
    	dialog->PhotoSettings->CroppedAspectRatio = aspectRatio;
    	auto captureOp = dialog->CaptureFileAsync(Windows::Media::Capture::CameraCaptureUIMode::Photo);
    	captureOp->Completed = ref new AsyncOperationCompletedHandler<Windows::Storage::StorageFile^>([](IAsyncOperation<Windows::Storage::StorageFile^> ^op)
    	{
    		auto file = op->GetResults();
    		// do what you want to do with the file
    	});
    	captureOp->Start();
    }
    

    Thanks
    Raman

    Tuesday, November 01, 2011 11:38 PM
  • Thanks Raman!

    Which language I should use .See we can Develop Library In both C++ and C# using WinRT.

    What is the Pros and Cons of using C++ and C#.See This Library will be used by UI to Display the Video.The UI can use any technology that Suits Window 8 Metro mode.So Please give your comment on this.

     


    • Edited by chris_vr Wednesday, November 02, 2011 11:08 AM Explantion
    Wednesday, November 02, 2011 11:02 AM
  • Btw, here is a code sample in C++:

    http://code.msdn.microsoft.com/Camera-Capture-UI-Sample-0b550324

    In order to answer your question, I really need to understand your scenarios better.  If you are going to do something computationally intensive, then C++ may be better.  The point is that feel free to use the language/technology in which you are most comfortable.

    Thanks

    Raman


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Thursday, November 03, 2011 12:59 AM
  • I have a related question.

    I am trying to covert the audio file captured using the default microphone on my Windows 8 tablet to a format that is acceptable to a voice to Text REST service. This service only accepts the following content types:  PCM, Speex, AMR QCELP and EVRC formats. 

    How do convert an audio file, encoded using the metro encoding profile[1],  to an PCM format ( 8 or 16 KHz 16 bit)

    Any help / insight you can offer is greatly appreciated.

     

    Thanks,

     

    [1]

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.mediaproperties.mediaencodingprofile.aspx

     

     

     

    Friday, June 15, 2012 2:38 PM
  • Hi,

    I am exactly in the same case as Vishwas Lele. Here is my question: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/bf2dc55c-337d-4792-8344-911634fc48de

    I need to transcode to the PCM format as Windows 8 does not natively generate this format (and I really don't understand why.....).

    Thanks for any help.



    Friday, June 22, 2012 11:44 PM
  • I finally used NAudio to change the MP3 format to WAV and then processed the Stream manually by removing the WAV header in order to get the raw PCM Stream. It works like a charm.

    Omid Bayani - KwypeSoft

    Monday, August 20, 2012 10:18 AM
  • Hi, Omid,

    Can you please describe how did you made NAudio working on WinRT ? AFAIK, it is not supported yet... Or there is a port?

    Thanks.

    Wednesday, September 26, 2012 8:31 AM
  • Hi Danil,

    I did not do anything special. I created a WinRT C# project and referenced naudio.dll. It compiled without any problem. I then referenced my own DLL in the client application which is developed in HTML/JavaScript.

    Why, do you face any issue?

    Omid.


    Omid Bayani - KwypeSoft

    Wednesday, September 26, 2012 7:09 PM
  • Does your application passed Certification Kit?

    NAudio have reference to System.Windows.Forms, so it fails certification in my case...

    Thanks.

    Thursday, September 27, 2012 6:20 AM
  • Unfortunately no... I discovered this sad point 2 weeks ago when I launched the local certification app. I'll check with the Microsoft team if this is really a blocking point for publication. Also, as we have access to Naudio source code, it may be possible to remove the external references (along with the C# methods) that make the app fail.

    Omid.


    Omid Bayani - KwypeSoft

    Thursday, September 27, 2012 7:59 AM
  • Omid, did you ever find a workaround to get PCM audio in windows 8 apps? I am currently stuck on this.
    Monday, April 15, 2013 7:10 AM
  • Hi, Joe,

    after several attempts I have finished on this solution

    http://code.msdn.microsoft.com/windowsapps/Windows-Audio-Session-22dcab6b

    Maybe it will be useful for you


    Monday, April 15, 2013 9:09 AM
  • Hi Joe,

    I finally asked Mark Heath if he could code this precise feature for me. And he made it successfully! I was happy to contribute financially so he could port back the code to Naudio if necessary.

    I did not look at the latest NAudio build but it may be compatible with Windows 8 certification now.

    Regards,

    Omid.


    Omid Bayani - KwypeSoft

    Monday, April 15, 2013 8:54 PM
  • Omid, could you provide the source code Mark wrote?
    Tuesday, April 16, 2013 4:26 PM
  • Hi Joe,

    I am gonna check with Mark as I paid for part of it (the layer that encodes from MP3 to PCM).

    I'll keep you informed.


    Omid Bayani - KwypeSoft

    Sunday, April 21, 2013 9:37 AM
  • Hi Joe,

    Sorry for the delay. Send me a mail and I'll send you back a zip file with the code.

    Omid.


    Omid Bayani - KwypeSoft

    Sunday, May 05, 2013 9:10 AM
  • Thanks Omid. I don't see your email address anywhere but I tweeted you my email address :)
    Wednesday, May 08, 2013 4:59 AM