Directshow, format type change filter

732 Views Asked by At

How can I change rcTarget in a filter?

Source and Target Rectangles in Video Renderers

I want, example in free pascal and DSpack. My project is to work with 720x576 video format. If I can change a filter rcTarget ex .: LAVSplitter pin VIDEO, I solved my problems.


I want to explain my problem:

My project and developed with DSPack and lazarus. I have to run a media file playlist and add text scrolling. Output DeckLink card analog or similar. For connect TV monitor means S-Video.

Now I see in the videowindow desktop and TV monitors connected to DeckLink, only original videos 720x576.

I want all video formats run. msdn site : Source and Target Rectangles in Video Renderers describes how to change rcTarget in videoinfoheader. I do not know how to write in pascal, used dspack. or is there another way to resize video? I have to build a new filter or I can change properties in rcTarget filter example: LAVSplitter?

my graph | sourcefile| -> 1920x1080 | LAV Splitter | -> 720x576 | LAV Decoder| -> Tee Filter| -> videowindows and DeckLink render

On the internet many examples to resize external device capture webcam, i do not find example code external device output. For this I ask for help.

I have an example for MPEG-2, not working. Where I go wrong?

// var
//    mt     : AM_Media_Type;
//    seqHdr : array [0..0] of byte;  //this is right?
//    pWIH   : MPEG2VIDEOINFO;
ZeroMemory(@Mt, sizeof(AM_MEDIA_TYPE));
Mt.MajorType := MEDIATYPE_Video;
Mt.SubType := MEDIASUBTYPE_RGB32;
Mt.FormatType := FORMAT_MPEG2_VIDEO;

Mt.cbFormat := sizeof(MPEG2VIDEOINFO) + sizeof(seqHdr); 
mt.pbFormat := CoTaskMemAlloc(mt.cbFormat);

if (mt.pbFormat = NULL) then exit;  //   ERROR 
ZeroMemory(mt.pbFormat, mt.cbFormat);

{ RCSRC.Left := 0;
RCSRC.Top:= 0;
RCSRC.Right := 0;
RCSRC.Bottom := 0;
}
pWIH.hdr.rcSource.Left:=0;    
pWIH.hdr.rcSource.Top:=0;
pWIH.hdr.rcSource.Right:=0;
pWIH.hdr.rcSource.Bottom:=0;
// pWIH.hdr.rcSource := RCSRC;
//  pWIH.hdr.rcTarget := Rect(0,0,720,576);
pWIH.hdr.rcTarget.Left:=0;
pWIH.hdr.rcTarget.Top:=0;
pWIH.hdr.rcTarget.Right:=576;
pWIH.hdr.rcTarget.Bottom:=720;
pWIH.hdr.AvgTimePerFrame := 278335;
pWIH.hdr.dwPictAspectRatioX := 4;
pWIH.hdr.dwPictAspectRatioY := 3;
pWIH.hdr.bmiHeader.biSize := 40;
pWIH.hdr.bmiHeader.biWidth := 720;
pWIH.hdr.bmiHeader.biHeight := 576;
pWIH.cbSequenceHeader := sizeof(seqHdr);
 CopyMemory(@pwih.dwSequenceHeader, @seqHdr, sizeof(seqhdr));
//-------------------------------------
SourceFilter.FindPin('Output',PinOutSource);
(VideoWindow1 as IBaseFilter).FindPin('Input',PIn_input);
PinOutSource.Connect(PIn_input,@mt);
1

There are 1 best solutions below

8
carmeloconny On

thank you, thank you,thank you. I want to use ( 3.Use this Resizer DMO filter ). I created Resize filter, as your example. OK. Now I want to use: (FResizerDMO as IMediaObject).SetOutputType for resize my video. I have difficulty, you can help me?

in site alax.info :

  1. CoCreateInstance the DSP as DMO and add it to DMO Wrapper Filter
  2. Use IWMResizerProps::SetFullCropRegion to initialize the DSP // I do not have to crop region?
  3. Connect input pin
  4. Set output type via IMediaObject::SetOutputType
  5. IGraphBuilder::ConnectDirect output pin

This above is correct?

I write this:

var pVIH :VIDEOINFOHEADER; mt :DMO_MEDIA_TYPE;
ZeroMemory(@mt, sizeof(DMO_MEDIA_TYPE));
mt.majortype := MEDIATYPE_Video;
mt.subtype := MEDIASUBTYPE_RGB32;
mt.formattype := FORMAT_VideoInfo;
//    ** I can not translate this **
//    VIDEOINFOHEADER * pVIH = (VIDEOINFOHEADER *)pmt->pbFormat;
//    pVIH := TVideoInfoHeader(mt.pbFormat^);   ????
pVIH.bmiHeader.biWidth := 720;
pVIH.bmiHeader.biHeight := 576;
pVIH.bmiHeader.biXPelsPerMeter:=9;
pVIH.bmiHeader.biYPelsPerMeter:=16;
pVIH.bmiHeader.biSizeImage := 720 * 480 * 3;
hr := (FResizerDMO as IMediaObject).SetOutputType(0,@mt,DMO_SET_TYPEF_CLEAR);
   if hr <> S_OK then showmessage('error'); // I receive error

correct this road? if it is correct you can help because it does not work.