Windows Media Foundation Audio and video capture small note

Source: Internet
Author: User

Write in front

I am a civilized person ... But sometimes I can not help but also to spit a few words:

1. I really can't keep up with the times, and now I'm still studying Windows application development ... Cough

2. DirectShow is a stupid x! I just want to get Camera bare data, but let me learn God horse all kinds. Ax, filter, graph ... The relevant information is small and obscure;

3. Wish Windows XP and its previous versions to exit the history stage early so that DirectShow is not required!

Audio and video capture after Windows 7, Media Foundation supports audio and video capture. The video capture device must support the UVC 1.1 driver. AudioThe acquisition device is supported through the Windows Audio Session API (WASAPI). The capture device is represented as a media Source object in Media Foundation, exposing the Imfmediasource interface. However, in general, applications do not use this interface directly, but instead use higher-level APIs, such as Source Reader, to control the acquisition device. Enumeration acquisition Devices: 1 Call the Mfcreateattributes function to create a property library; 2 Set the Mf_devsource_attribute_source_type property (Mf_devsource_attribute_source_ Type_audcap_guid or Mf_devsource_attribute_source_type_vidcap_guid); 3 calls the Mfenumdevicesources function to get a set of IMFActivate pointers. Each pointer is a device; 4 call the getallocatedstring function to get the device name, where 4.1 uses the  getallocatedstring function  mf_devsource_attribute_ The Friendly_name parameter can get the display name 4.2  with the  getallocatedstring function  mf_devsource_attribute_source_type_vidcap_ The Symbolic_link parameter can get the physical name of the video capture device, the name is unique, but it is not good to read 4.3  with  getallocatedstring function  mf_devsource_attribute_ The source_type_audcap_endpoint_id  parameter can get the physical name of the audio capture device, the name is unique, but it is not good to read 5 call Imfactivate::activateobject or Mfcreatedevicesource method to create an instance of an available Media Source object. For a specific acquisition device (created media source), get the format supported by the device and set the acquisition format: 1 call Imfmediasource::createpresentationdescriptor to get the mediaOurce) The Performance descriptor (presentation descriptor) 2 calls Imfpresentationdescriptor::getstreamdescriptorbyindex gets the stream descriptor of the video stream (stream Descriptor) 3 Call Imfstreamdescriptor::getmediatypehandler to get the stream descriptor of the media type handle (Imfmediatypehandler) 4 call Imfmediatypehandler :: Getmediatypecount and Getmediatypebyindex to get each destination format (imfmediatype, each destination format contains many attributes, such as width, sample format, frame rate), in addition, tutorials have some useful functions for printing Imfattributes. 5 Finally,  imfmediatypehandler::setcurrentmediatype sets the format of the specified entry (imfmediatype). If you want to modify a property of  imfmediatype (such as Frame rate), call  imfmediatype::setitem to set specific properties (such as  mf_mt_frame_rate). Depends on the code to understand.

Related documents:

https://msdn.microsoft.com/en-us/library/dd317912.aspxhttps://msdn.microsoft.com/en-us/library/ Dd940326.aspxhttps://msdn.microsoft.com/en-us/library/dd940328.aspx (the process of loss in the middle of equipment use, to be learned) https://msdn.microsoft.com /en-us/library/ee663602.aspxhttps://msdn.microsoft.com/en-us/library/aa473818.aspx (Media type)

Other features

Video capture and display (MFCAPTURED3D): https://msdn.microsoft.com/en-us/library/dd743690.aspx

Audio/Video Acquisition + coding (transcode): https://msdn.microsoft.com/en-us/library/ff485863.aspx

Play media files: https://msdn.microsoft.com/en-us/library/ms703190.aspx

Code address

In the Samples\multimedia\mediafoundation directory of the Windows SDK

Windows Media Foundation Audio and video capture small note

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.