directshow - How to work with AMMediaType for video filters -
i using video resizer dsp video resizer dsp resize video. work lazarus free pascal , dspack.
this site explains how use: http://alax.info/blog/1371
- cocreateinstance dsp dmo , add dmo wrapper filter
- use iwmresizerprops::setfullcropregion initialize dsp
- connect input pin
- set output type via imediaobject::setoutputtype
- igraphbuilder::connectdirect output pin
i write this:
//create resizer dmo hr := cocreateinstance(clsid_dmowrapperfilter, nil, clsctx_all, iid_ibasefilter, fresizerdmo); if failed(hr) exit; //clsid_cvideoresizerdmo = '{1ea1ea14-48f4-4054-ad1a-e8aee10ac805}' hr := (fresizerdmo idmowrapperfilter).init( clsid_cvideoresizerdmo, dmocategory_video_effect ); if failed(hr) exit; //add filter graph (fgrender igraphbuilder).addfilter( fresizerdmo, 'resizer' ); if failed(hr) exit; // end create fresizerdmo in graph // set output type via imediaobject::setoutputtype , create structure zeromemory(@mt, sizeof(dmo_media_type)); mt.majortype := mediatype_video; mt.subtype := mediasubtype_rgb32; mt.formattype := format_videoinfo; mt.lsamplesize := pvih.bmiheader.bisize; fillchar(pvih, sizeof(tvideoinfoheader), 0); mt.pbformat := cotaskmemalloc(sizeof(videoinfoheader)); pvih := tvideoinfoheader(mt.pbformat^); pvih.bmiheader.biwidth := 720; pvih.bmiheader.biheight := 576; pvih.bmiheader.bixpelspermeter:=9; pvih.bmiheader.biypelspermeter:=16; pvih.bmiheader.bisize := sizeof(tbitmapinfoheader); pvih.bmiheader.bisizeimage := 720 * 576 * 4; // connect pin , next hr := (fresizerdmo imediaobject).setoutputtype (0,@mt,dmo_set_typef_clear);
in hr receive dmo_e_type_not_accepted. go wrong? can me? thank you.
cross-post of thread on topic: how configure resizer dmo?.
i don't think code around pbformat correct. apparently, fillchar cause memory access vioaltion early. looks you're modifying copy of allocated data (pvih declaration not shown). bixpelspermeter/biypelspermeter looks weird though think can accepted. don't initilaize rest of tvideoinfoheader fields.
just watch pvih in debuger before call , see structure not well-defined.
start initializing explicitly fields of videoinfoheader
structure.
Comments
Post a Comment