× Components and Libraries for Audio and Video Development, discussions, problems and suggestions

Question Dspack, resize format type media video

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago - 6 years 7 months ago #6898 by Carmelo
Hello
how to change the format type to media video?
which filter to use?
I have to use format standard out: 720x576

hr := (fgRender as IGraphBuilder).AddSourceFilter(StringToOleStr('C:\film\01\video.mp4'),
'Source Filter', SourceFilter);

ZeroMemory(@Mt, sizeof(AM_MEDIA_TYPE));
Mt.MajorType := MEDIATYPE_Video;
Mt.SubType := MEDIASUBTYPE_RGB32;
Mt.FormatType := FORMAT_MPEG2_VIDEO;
Mt.cbFormat := sizeof(MPEG2VIDEOINFO) + sizeof(SegHdr);
Mt.pbFormat := CoTaskMemAlloc(Mt.cbFormat);
ZeroMemory(Mt.pbFormat, Mt.cbFormat);

RCSRC.Left := 0;
RCSRC.Top:= 0;
RCSRC.Right := 0;
RCSRC.Bottom := 0;

pWIH.hdr.rcSource := RCSRC;
//*****
pWIH.hdr.rcTarget.Left:=0;
pWIH.hdr.rcTarget.Top:=0;
pWIH.hdr.rcTarget.Bottom:=576;
pWIH.hdr.rcTarget.Right:=720;

// pWIH.hdr.rcTarget := Rect(0,0,720,576);
//****
pWIH.hdr.AvgTimePerFrame := 333667;
// pWIH.hdr.AvgTimePerFrame := 278335;
pWIH.hdr.dwPictAspectRatioX := 4;
pWIH.hdr.dwPictAspectRatioY := 3;
pWIH.hdr.bmiHeader.biSize := 40;
pWIH.hdr.bmiHeader.biWidth := 720; //720
pWIH.hdr.bmiHeader.biHeight := 576; //480
pWIH.cbSequenceHeader := sizeof(segHdr);

CopyMemory(@pWIH.dwSequenceHeader, @segHdr, sizeof(seghdr));

msdn.microsoft.com/en-us/library/windows...407277(v=vs.85).aspx
This works only MPG2 file.

how can I work with all video formats?
and which filter to use?
****************************************************************************
msdn.microsoft.com/en-us/library/windows...407277(v=vs.85).aspx
can I use this for my project?
There is an example code with DSpack?


thank you for help me.
Last edit: 6 years 7 months ago by Carmelo.

Please Log in or Create an account to join the conversation.

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago #6919 by Carmelo
Replied by Carmelo on topic Dspack, resize format type media video
no one can help me?
I declare AM_MEDIA_TYPE and after
   SourceFilter.FindPin('Output',PinOutSource);
   DefaultAudioFilter.FindPin('Input',PInIntermediateFilter);
  case PinOutSource.Connect(PInIntermediateFilter,@mt) of
          S_OK                                        : showmessage('S_OK       ');
          E_POINTER                            : showmessage('E_POINTER   ');
          VFW_E_NOT_CONNECTED : showmessage('VFW_E_NOT_CONNECTED   );
          VFW_S_PARTIAL_RENDER : showmessage('VFW_S_PARTIAL_RENDER');
          E_ABORT                               : showmessage('E_ABORT   ');
          VFW_E_NOT_IN_GRAPH      : showmessage('VFW_E_NOT_IN_GRAPH ');
          VFW_E_CANNOT_CONNECT: showmessage('VFW_E_CANNOT_CONNECT');
   end;
I receive " E_POINTER " error.
I have to change the filter to assign "@mt".

or I wrong statement?
pWIH : MPEG2VIDEOINFO;
SeqHdr : array[0..0] of DWORD;

I have tried with many filters, I get more and 'E_POINTER '

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
6 years 7 months ago #6920 by Sternas Stefanos
Replied by Sternas Stefanos on topic Dspack, resize format type media video
Sir
Attach a sample project here (zip first)

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 7 months ago - 6 years 7 months ago #6921 by Carmelo
Replied by Carmelo on topic Dspack, resize format type media video
thank you Sternas :)

File Attachment:

File Name: project_ty...yout.zip
File Size:544 KB


this code resize mpeg2 format type, does not work!
where I go wrong?
   mt        : AM_Media_Type;
  rcSrc    : Rect; 
  seqHdr : array[0..0] of Byte;   // this is right?
  pWIH    : MPEG2VIDEOINFO;
//***************  type pin ******************
  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;   [b]// ERROR    [/b]

  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));
  // ********  connect pin *******************
  SourceFilter.FindPin('Output',PinOutSource);
 (VideoWindow1 as IBaseFilter).FindPin('Input',PIn_input);
 case PinOutSource.Connect(PIn_input,@mt) of
   S_OK                : showmessage('S_OK         ');
   E_POINTER           : showmessage('E_POINTER    ');
   VFW_E_NOT_CONNECTED : showmessage('VFW_E_NOT_CONNECTED ');
   VFW_E_CANNOT_CONNECT : showmessage('VFW_E_CANNOT_CONNECT');
   VFW_E_NOT_IN_GRAPH  : showmessage('VFW_E_NOT_IN_GRAPH ');
 end;
Last edit: 6 years 7 months ago by Carmelo.

Please Log in or Create an account to join the conversation.

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 6 months ago #6978 by Carmelo
Replied by Carmelo on topic Dspack, resize format type media video
I am using Video Resizer DSP to resize my video.

This site explains how to use: alax.info/blog/1371
•CoCreateInstance the DSP as DMO and add it to DMO Wrapper Filter
•Use IWMResizerProps::SetFullCropRegion to initialize the 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) then EXIT;
//CLSID_CVideoResizerDMO = '{1ea1ea14-48f4-4054-ad1a-e8aee10ac805}'
Hr := (FResizerDMO as IDMOWrapperFilter).Init( CLSID_CVideoResizerDMO,  
DMOCATEGORY_VIDEO_EFFECT );
if FAILED(Hr) then EXIT;
//Add filter to graph
(fgRender as IGraphBuilder).AddFilter( FResizerDMO, 'Resizer' );
if FAILED(Hr) then EXIT; 
// end create FResizerDMO in my graph

// Set output type via IMediaObject::SetOutputType and 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 and next
hr := (FResizerDMO as IMediaObject).SetOutputType
(0,@mt,DMO_SET_TYPEF_CLEAR);
in hr i receive DMO_E_TYPE_NOT_ACCEPTED. I will not be able to assign @mt in SetOutputType.
where I go wrong? can anyone help me? thank you.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
6 years 6 months ago - 6 years 6 months ago #6979 by Sternas Stefanos
Replied by Sternas Stefanos on topic Dspack, resize format type media video
Please Sir give us more info
-Your Host OS?
-Your CodeTyphon Version ?
-Your Project Target OS ?

Why do you use mt.subtype := MEDIASUBTYPE_RGB32;

This link must help you, and this

and this

PilotLogic Architect and Core Programmer
Last edit: 6 years 6 months ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 6 months ago #6981 by Carmelo
Replied by Carmelo on topic Dspack, resize format type media video
thanks for reply.
I use CodeTyphon 5.2 for win. My OS is win7 32 bit.
My project must play a playlist of video files different format, i have to resize in standard format
SD 720x576 16/9 or 4/3, and insert the scrolling text and a logo in the video.
I have tried various solutions without success.
Now I'm trying Video Resizer DSP
I have managed to create filter ( VideoResizerDMO ) in Graph. next I have to add a structure format. I have difficulty in this.
in the site forum msdn have written to me this:

I don't think your code around pbFormat is correct. Apparently, FillChar is to cause memory access vioaltion as you do it too early. Then it looks like you're modifying a copy of allocated data (pVIH declaration is not shown). Then biXPelsPerMeter/biYPelsPerMeter looks somewhat weird even though I think this can be accepted. Then you don't initilaize the rest of TVideoInfoHeader fields.

Just watch pVIH in debuger before the call and you will see the structure is not well-defined.

you can help me to correct my code structure ?

Please Log in or Create an account to join the conversation.

  • Carmelo
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 6 months ago #7003 by Carmelo
Replied by Carmelo on topic Dspack, resize format type media video
IWMResizerProps interface there is in DSPack ?
IWMResizerProps interface
if there how to call?

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
6 years 6 months ago #7004 by Sternas Stefanos
Replied by Sternas Stefanos on topic Dspack, resize format type media video
No Sir

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.