Set the pin attribute of video capture source in the program

Source: Internet
Author: User

The video capture Source Filter automatically generated by dshow from the WDM driver has a pin property page, which must have been known and met by all experts. In this pin property page, you can set frame rate and lens resolution.

Can't I set the frame rate and the lens resolution from the program?

Of course, you can set it through a program: Use iamstreamconfig: setformat.

First, you get the ipin pointer of the pin you want to set; then QueryInterface gets the iamstreamconfig interface, through which you can set it. You can refer to the amcap example, which shows the demo using the iamstreamconfig interface.

Mr Lu spoke too well!
That's all!

Section code for your reference:

// Set the video output Pin Size and return the set value <br/> // If bmaxsize is true, the maximum supported video size is output, otherwise, the output is based on the specified size <br/> hresult ccardvideoopt: setvideosize (ibasefilter * pvideofilter <br/>, out Int & iwidth, out Int & iheight, in bool bmaxsize) <br/> {<br/> hresult hR = noerror; <br/> iamstreamconfig * pamstreamconfig = NULL; <br/> ipin * poutpin = NULL; <br/> videoinfoheader * pvihtmp; <br/> int idefaultw, idefaulth; // default video width and height </P> <p> // am_media_t Ype * pmediatype; <br/> poutpin = cgraphutility: getfirstpin (pvideofilter, pindir_output); <br/> If (poutpin = NULL) <br/>{< br/> return e_fail; <br/>}< br/> hR = poutpin-> QueryInterface (iid_iamstreamconfig, (void **) & pamstreamconfig ); <br/> If (failed (HR) <br/>{< br/> safe_release (poutpin); <br/> return hr; <br/>}</P> <p> int icount, isize; <br/> video_stream_config_caps SCC; <br/> am_media_type * PMT; </P> <p> H R = pamstreamconfig-> getnumberofcapabilities (& icount, & isize); <br/> If (sizeof (SCC )! = Isize) <br/>{< br/> safe_release (poutpin); <br/> safe_release (pamstreamconfig); <br/> return e_fail; <br/>}</P> <p> for (INT I = 0; I <icount; I ++) <br/>{< br/> hR = pamstreamconfig-> getstreamcaps (I, & PMT, (byte *) (& SCC )); <br/> pvihtmp = (videoinfoheader *) (PMT-> pbformat); </P> <p> If (PMT-> subtype = mediasubtype_rgb32) <br/> break; <br/>}< br/> idefaultw = pvihtmp-> bmiheader. biwidth; <br/> idefaulth = pvihtmp-> BM Iheader. biheight; </P> <p> If (hR = s_ OK) <br/>{< br/> // find the biggest output size. <br/> If (bmaxsize) <br/>{< br/> iwidth = SCC. maxoutputsize. CX; <br/> iheight = SCC. maxoutputsize. cy; <br/>}< br/> long cbpixel = pvihtmp-> bmiheader. bibitcount/8; // bytes per pixel in rgb32 </P> <p> // modify the format block. <br/> videoinfoheader * pvih = <br/> (videoinfoheader *) (PMT-> pbformat); <br/> pvih-> bmiheader. biw Idth = iwidth; <br/> pvih-> bmiheader. biheight = iheight; </P> <p> // set the sample size and image size. <br/> // (round the image width up to a DWORD boundary .) <br/> PMT-> lsamplesize = pvih-> bmiheader. bisizeimage = <br/> (iwidth + 3 )&~ 3) * iheight * cbpixel; </P> <p> // now set the format. <br/> hR = pamstreamconfig-> setformat (PMT); <br/> If (failed (HR) <br/>{< br/> iwidth = idefaultw; <br/> iheight = idefaulth; <br/> pvih-> bmiheader. biwidth = iwidth; <br/> pvih-> bmiheader. biheight = iheight; <br/> hR = pamstreamconfig-> setformat (PMT); <br/> If (failed (HR )) <br/>{< br/> safe_release (poutpin); <br/> safe_release (pamstreamconfig); <br/> return hr; <br/>}</P> <p> safe_release (poutpin); <br/> safe_release (pamstreamconfig); <br/> return hr; <br/>}< br/> safe_release (poutpin); <br/> safe_release (pamstreamconfig); </P> <p> return hr; <br/>}</P> <p>

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.