2

I am trying to configure the output pin of live gamer portable 2 plus for lower frame rates. Through GraphStudioNext I can access the configuration through the capture pin and change the frame rate.

However when I try IAMStreamConfig on the capture pin through the API, it will only allow me to select the default settings and not use the same frame rates I can do through GraphStudioNext.

Is there a different interface I should be using to get the output pin stream config seen in GraphStudioNext?

Filtergraph example

Properties form

Below is the default Delphi routine to send the standard formats, I modified this so I changed the frame rate and kept all the other parameters and it worked.

      if (Format.Width = MediaHeader.bmiHeader.biWidth) and
        (Format.Height = MediaHeader.bmiHeader.biHeight) and
        (Format.AvgTimePerFrame = MediaHeader.AvgTimePerFrame) and
        (Format.BitsPerPixel = MediaHeader.bmiHeader.biBitCount) then
      begin
        MediaHeader.AvgTimePerFrame := NewRate;
        CheckNull(AMStreamConfig, 'IAMStreamConfig');
        CheckError(AMStreamConfig.SetFormat(MediaType));
        Exit;
      end;

1 Answers1

4

This is a bit complicated because some cameras might support rates flexibly from within certain range and other might have fixed set of supported rates. Generally speaking you should be able to build a media type with desired frame rate and the device would capture as many as it can within the requested amount (or some would just ignore your setting).

However the canonical behavior is to enumerate formats with IAMStreamConfig so that you have MinFrameInterval and MaxFrameInterval range for a format of interest. Then (optionally) also use IAMVideoControl::GetFrameRateList to retrieve set of supported/suggested rates, the one that you see in GraphEdit/GraphStudio.

Then you can update a media type and instruct the camera to use a media type with specific frame rate via IAMStreamConfig::SetFormat.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks for the quick answer. I tried changing the rate to one selectable from graphstudio using iamstreamconfig::setformat. However it always just selects one of the 10 published rates. But through graph studio next I can set the rate to the value I am entering. Default is 1920x1080 mjpg 60fps 24bpp, if I try 30 fps through graph studio that works, but via the directshow code it doesn't. Does set format take different argument types? – Barry Andrews May 30 '19 at 10:41
  • When you selected a format from GraphStudioNext you can review effective media type on a connected pin. In your code you are supposed to have the same media type built, then `IAMStreamConfig::SetFormat` and pin connection should establish a pin connection with that format. – Roman R. May 30 '19 at 10:48
  • I have added the original code to set the available formats, I have modified this to not check the frame rate, should I really be populating the FORMAT_Videoinfo from scratch, or would these commands need a FORMAT_VideoInfo2 structure? – Barry Andrews May 30 '19 at 11:18
  • You can modify data before `AMStreamConfig.SetFormat` call. Make sure to also do this before you connect pins. – Roman R. May 30 '19 at 11:27
  • the current code sets the format after the connection is made. I can also make the changes to graphstidionext after making the connection. I am making the changes before I set the format, but the filter just goes to the nearest standard default. When I do the same in reconditioned it changes just the route. – Barry Andrews May 30 '19 at 12:14
  • You must `SetFormat` before connecting the pins. See also [this Q](https://stackoverflow.com/a/9835133/868014). – Roman R. May 30 '19 at 12:45
  • problem was between the computer and the keyboard. I wasn't changing the FORMAT_VideoInfo like I thought I was. Now that I change that it works, thanks for your input, definitely helped. – Barry Andrews May 30 '19 at 13:31