Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to change resolution when rendering video file by DirectShow

664 views
Skip to first unread message

James Duy Trinh (VietDoor)

unread,
Apr 24, 2009, 8:36:20 PM4/24/09
to
Hi all,

I used DirectShow to render a video file or webcam. With webcam, i can get
IID_IAMStreamConfig to change resolution, but not video file.
Any way to do this? Thanks in advance.

This is code worked with webcam, not video file:
// Variables
ICaptureGraphBuilder2 * m_pBuilder;
IAMStreamConfig* m_pVSC;

// Get IID_IAMStreamConfig
hr = m_pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
m_pSrcFilter, IID_IAMStreamConfig, (void **)&m_pVSC);
// Get current AM_MEDIA_TYPE
AM_MEDIA_TYPE *pmt;
hr = m_pVSC->GetFormat(&pmt);
// Change info
...
// Set new AM_MEDIA_TYPE
hr = m_pVSC->SetFormat(pmt);


Ralf Globisch

unread,
Apr 25, 2009, 5:48:30 AM4/25/09
to
You can't change the resolution of a video file using that interface
but you could alternatively scale the video to your desired
resolution.
However you might loose quality by doing that (if you scale up) since
you can't generate what doesn't exist in the original file. There's a
free open-source scale filter for RGB media at http://sourceforge.net/projects/videoprocessing/

You can try it out in graphedit and use the property page to configure
it.

On Apr 25, 2:36 am, "James Duy Trinh \(VietDoor\)"

James Duy Trinh (VietDoor)

unread,
Apr 28, 2009, 7:59:09 PM4/28/09
to
Hi Globisch,

Any example to use this library?

"Ralf Globisch" <Ralf.G...@gmail.com> wrote in message
news:0f387de6-5d96-4cfc...@y9g2000yqg.googlegroups.com...

Ralf Globisch

unread,
Apr 29, 2009, 7:13:08 AM4/29/09
to
Unfortunately not yet, but I'm working on it. For now you can see if
it meets your requirements using Graphedit.

1) Download the Setup.msi file and install the filters
2) Start Graphedit
3) Insert some kind of RGB source filter (PushSource, AVI, webcam)
4) Insert scale filter (You can find it under the directshow filters
under the name "Meraka RTVC Scale Filter"
5) Connect the source filter to the scale filter
6) Configure the scale filter using the filter property page.
7) Render the rest of the graph and play the graph.

Note that there is a limitation on the scale filter, you cannot scale
up by more than a factor of 2.

If you want to use the scale filter programmatically you can do the
following (The example code uses COM smart pointers):

....................
IBaseFilterPtr pScaleFilter = NULL;
...
ISettingsInterfacePtr pSettingsInterface = pScaleFilter;
char szParamValue[255];
int nLength = 0;
HRESULT hr;
hr = pSettingsInterface->GetParameter("targetwidth", 255,
szParamValue, nLength);
hr = pSettingsInterface->GetParameter("targetheight", 255,
szParamValue, nLength);
hr = pSettingsInterface->SetParameter("targetwidth", "800");
hr = pSettingsInterface->SetParameter("targetheight", "600");
....................


On Apr 29, 1:59 am, "James Duy Trinh \(VietDoor\)"


<vietd...@gmail.com> wrote:
> Hi Globisch,
>
> Any example to use this library?
>

> "Ralf Globisch" <Ralf.Globi...@gmail.com> wrote in message


>
> news:0f387de6-5d96-4cfc...@y9g2000yqg.googlegroups.com...
> You can't change the resolution of a video file using that interface
> but you could alternatively scale the video to your desired
> resolution.
> However you might loose quality by doing that (if you scale up) since
> you can't generate what doesn't exist in the original file. There's a

> free open-source scale filter for RGB media athttp://sourceforge.net/projects/videoprocessing/

Ralf Globisch

unread,
Apr 29, 2009, 4:39:57 AM4/29/09
to
You can test it using Graphedit.
Unfortunately I'm still working on that. For now the easiest way to
see if the filter meets your requirements is using Graphedit:
1) Install the Setup.msi package.
2) Then start Graphedit.
3) Insert some RGB source into the graph (avi, push source, web cam,
etc)
4) Insert the scale filter into the graph. You'll find the scale
filter under the DirectShow filters under the name "Meraka RTVC Scale
Filter".
5) Connect the source to the scale filter
6) Configure the scale filter using the filter property page. Keep in
mind that one of the limitations of this filter is that you can only
scale up by a factor of 2.
7) Render the output pin of the scale filter.
8) Play the graph

Note that you must configure the scale filter *before* you render the
rest of the graph since this filter does not support dynamic
reconfiguration at present.

If you wish to use and configure the scale filter programmatically,
you can do this accessing the ISettingsInterface COM interface of the
filter.
Note that the example is using COM smart pointers:

IBaseFilterPtr pScaleFilter = NULL;
...
ISettingsInterfacePtr pSettingsInterface = pScaleFilter;
char szParamValue[255];
int nLength = 0;
HRESULT hr;
hr = pSettingsInterface->GetParameter("targetwidth", 255,
szParamValue, nLength);
hr = pSettingsInterface->GetParameter("targetheight", 255,
szParamValue, nLength);
hr = pSettingsInterface->SetParameter("targetwidth", "800");
hr = pSettingsInterface->SetParameter("targetheight", "600");
....

On Apr 29, 1:59 am, "James Duy Trinh \(VietDoor\)"


<vietd...@gmail.com> wrote:
> Hi Globisch,
>
> Any example to use this library?
>

> "Ralf Globisch" <Ralf.Globi...@gmail.com> wrote in message


>
> news:0f387de6-5d96-4cfc...@y9g2000yqg.googlegroups.com...
> You can't change the resolution of a video file using that interface
> but you could alternatively scale the video to your desired
> resolution.
> However you might loose quality by doing that (if you scale up) since
> you can't generate what doesn't exist in the original file. There's a

> free open-source scale filter for RGB media athttp://sourceforge.net/projects/videoprocessing/

James Duy Trinh

unread,
May 7, 2009, 10:50:55 PM5/7/09
to
But i need a scale filter before samegrabber filter, so we can get frame
with the respected size.

"Ralf Globisch" <Ralf.G...@gmail.com> wrote in message

news:0fa47c2f-84c4-4f61...@x1g2000prh.googlegroups.com...

Ralf Globisch

unread,
May 8, 2009, 4:04:45 AM5/8/09
to
In that case I would recommend you first test the scale filter using
graphedit to see how it works and what the output is.

Once you've done that you can follow the programmatic approach.
1) Simply add your source, the scale filter to your graph. (You'll
have to download the source code from sourceforge using some
subversion client for this. The GUID for the scale filter is in the
ScaleFilter.h header file. Add the scale filter to the graph using the
GUID)
2) Connect the source to the scale filter. Configure the scale filter
using the ISettingsInterface like shown in my previous posts.
3) Add a sample grabber and a renderer to the graph.
4) Build the rest of the graph.(configure the sample grabber callback,
connect the rest of the graph, etc)

On May 8, 4:50 am, "James Duy Trinh" <vietd...@gmail.com> wrote:
> But i need a scale filter before samegrabber filter, so we can get frame
> with the respected size.
>

0 new messages