Welcome, Guest
Username: Password: Remember me
Components and Libraries for Audio and Video Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Dspack, resize format type media video 9 years 2 weeks ago #6898

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
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.

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

Last edit: by Carmelo.

Dspack, resize format type media video 9 years 1 week ago #6919

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
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.

Dspack, resize format type media video 9 years 1 week ago #6920

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4506
  • Thank you received: 1100
Sir
Attach a sample project here (zip first)
PilotLogic Architect and Core Programmer

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

Dspack, resize format type media video 9 years 1 week ago #6921

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
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;

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

Last edit: by Carmelo.

Dspack, resize format type media video 8 years 11 months ago #6978

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
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.

Dspack, resize format type media video 8 years 11 months ago #6979

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4506
  • Thank you received: 1100
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

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

Last edit: by Sternas Stefanos.

Dspack, resize format type media video 8 years 11 months ago #6981

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
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.

Dspack, resize format type media video 8 years 11 months ago #7003

  • Carmelo
  • Carmelo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
IWMResizerProps interface there is in DSPack ?
IWMResizerProps interface
if there how to call?

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

Dspack, resize format type media video 8 years 11 months ago #7004

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4506
  • Thank you received: 1100
No Sir
PilotLogic Architect and Core Programmer

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

  • Page:
  • 1