I decided to do it via code, because CPU usage is important, here's what I came up with by searching on Google.
And it works like a charm, using OSD feature in ffdshow, I see the input and output are changed, and NO MORE GREEN BAR !
Thanks, Merci !
I think this needs to be done before connecting it, but once the capFilter is created of course.
//Resize the Input Source so that green bar goes away
SetConfigParms(pBuilder, pAVerMedia7231AnalogCapture, 0, 720, 480);
//connect AVerMedia 7231 Analog Capture and Smart Tee
hr = graphBuilder.ConnectDirect(GetPin(pAVerMedia7231AnalogCapture, "Capture"), GetPin(pSmartTee, "Input"), null);
checkHR(hr, "Can't connect AVerMedia 7231 Analog Capture and Smart Tee");
The resize function :
// Set the Framerate, and video size
private void SetConfigParms(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, int iFrameRate, int iWidth, int iHeight)
{
int hr;
object o;
AMMediaType media;
IAMVideoControl videoControl = capFilter as IAMVideoControl;
Guid cat = PinCategory.Capture;
Guid med = MediaType.Null;
Guid iid = typeof(IAMStreamConfig).GUID;
hr = capGraph.FindInterface(cat, med, capFilter, iid, out o);
if (hr != 0)
{
// If not found, try looking for a video media type
med = MediaType.Video;
hr = capGraph.FindInterface(cat, med, capFilter, iid, out o);
if (hr != 0)
o = null;
}
if (hr != 0)
{
// If not found, try looking for a video media type
med = MediaType.AnalogVideo;
hr = capGraph.FindInterface(cat, med, capFilter, iid, out o);
if (hr != 0)
o = null;
}
IAMStreamConfig videoStreamConfig = (IAMStreamConfig)o;
if (videoStreamConfig == null)
{
MessageBox.Show("Failed to get IAMStreamConfig");
}
videoStreamConfig.GetFormat(out media);
try
{
DsError.ThrowExceptionForHR(hr);
// copy out the videoinfoheader
VideoInfoHeader v = new VideoInfoHeader();
Marshal.PtrToStructure(media.formatPtr, v);
// if overriding the framerate, set the frame rate
if (iFrameRate > 0)
{
v.AvgTimePerFrame = 10000000 / iFrameRate;
}
// if overriding the width, set the width
if (iWidth > 0)
{
v.BmiHeader.Width = iWidth;
}
// if overriding the Height, set the Height
if (iHeight > 0)
{
v.BmiHeader.Height = iHeight;
}
// Copy the media structure back
Marshal.StructureToPtr(v, media.formatPtr, false);
// Set the new format
hr = videoStreamConfig.SetFormat(media);
DsError.ThrowExceptionForHR(hr);
DsUtils.FreeAMMediaType(media);
media = null;
if (videoControl != null)
{
VideoControlFlags pCapsFlags;
IPin pPin = DsFindPin.ByCategory(capFilter, PinCategory.Capture, 0);
hr = videoControl.GetCaps(pPin, out pCapsFlags);
DsError.ThrowExceptionForHR(hr);
if ((pCapsFlags & VideoControlFlags.FlipVertical) > 0)
{
hr = videoControl.GetMode(pPin, out pCapsFlags);
DsError.ThrowExceptionForHR(hr);
hr = videoControl.SetMode(pPin, 0);
}
}
}
finally
{
Marshal.ReleaseComObject(videoStreamConfig);
}
}