FORUMS: list search recent posts

Capture Resolution DirectShow

COW Forums : Blackmagic Design

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Robert Huff
Capture Resolution DirectShow
on Feb 18, 2011 at 12:46:44 am

I'm trying to view a live video feed from the Intensity Pro GFX Card with an HDMI Input at 1080i @ 59.94
To a Frame using DirectShow 2005.

I've Got my Filters set up
Magics Card -> Infinite Pin Tee -> Out1 & Out2

Out1 -> Sample Grabber -> Null Renderer
Out2 -> AVI Decompressor -> Video Mixing Renderer9 In Windowless Mode.

Problem
1) I'm getting a Black Video, and I believe it's due to the Resolution not being set.
How do I set the IBaseFilter for the Card or the iPIN card to the correct Resolution in c# ?

Current Filter Code is as follows.
static void BuildGraph(IGraphBuilder pGraph)
{

int hr = 0;
#region Find Video Capture Card
DsDevice[] CardFinder = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
// Magics Card should be CardFinder[0]
// graph builder
ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
hr = pBuilder.SetFiltergraph(pGraph);
checkHR(hr, "Can't SetFiltergraph");
#endregion
#region Create Connection to Capture Card
Guid HDYC = new Guid(0x43594448, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);

IBaseFilter pDecklinkVideoCature;// = CreateFilterbyName(@"Decklink Video Capture", CLSID_VideoCaptureSource);
IFilterGraph2 TempFilter = (IFilterGraph2)new FilterGraph();
hr = TempFilter.AddSourceFilterForMoniker(CardFinder[0].Mon,null, CardFinder[0].Name,out pDecklinkVideoCature);
checkHR(hr, "Can't Find Camera");
hr = pGraph.AddFilter(pDecklinkVideoCature, "Decklink Video Capture");
checkHR(hr, "Can't add Decklink video Capture to graph");
// Configure pDecklinkVideoCature for 1080i @ 59.94fps somehow
AMMediaType VideoOutMediaType = new AMMediaType();
VideoOutMediaType.majorType = MediaType.Video;
//VideoOutMediaType.subType = MediaSubType;
//VideoOutMediaType.fixedSizeSamples;
//VideoOutMediaType.formatPtr;
//VideoOutMediaType.formatSize;
//VideoOutMediaType.formatType;
//VideoOutMediaType.sampleSize;
//VideoOutMediaType.temporalCompression;
//VideoOutMediaType.unkPtr;
IPin VideoOutPin = GetVPin(pDecklinkVideoCature, "Capture");

checkHR(hr, "Can't Get Pin Query");
#endregion
#region Create Sample Grabber
IBaseFilter SampleGrabberFilter = (IBaseFilter)new SampleGrabber();
// Configure SampleGrabberFilter
AMMediaType SampleMediaType = new AMMediaType();
SampleMediaType.majorType = MediaType.Video;
SampleMediaType.subType = MediaSubType.RGB24;
SampleMediaType.formatType = FormatType.VideoInfo;

hr = pGraph.AddFilter(SampleGrabberFilter, "Sample Grabber");
checkHR(hr, "Can't Add Sample Grabber");
IPin SGFIn = GetPin(SampleGrabberFilter, "Input");
IPin SGFOut = GetPin(SampleGrabberFilter, "Output");
#endregion
#region Create Null Renderer
IBaseFilter VideoNullRenderer = (IBaseFilter)new NullRenderer();
hr = pGraph.AddFilter(VideoNullRenderer, "Null Renderer");
checkHR(hr, "Can't Create Null Renderer");
IPin NullIn = GetPin(VideoNullRenderer, "In");
#endregion
#region Create Color Space Converter
//IBaseFilter ColorSpaceFilter = (IBaseFilter) new ;
#endregion
#region Create Infinite Pin Tree Filter
IBaseFilter InfinitePinTreeFilter = (IBaseFilter)new InfTee();
hr = pGraph.AddFilter(InfinitePinTreeFilter, "Infinite Pin Tee");
checkHR(hr, "Can't Add Pin Tee");
IPin IPTIn = GetPin(InfinitePinTreeFilter, "Input");
IPin IPTOut1 = GetPin(InfinitePinTreeFilter, "Output1");
#region Connect IPTOut -> Sample Grabber -> Null renderer
hr = pGraph.ConnectDirect(VideoOutPin, IPTIn, VideoOutMediaType);
//hr = pGraph.Connect(VideoOutPin, IPTIn);
checkHR(hr, "Can't Connect Camera to Infinite Pin Tee");
//hr = pGraph.ConnectDirect(IPTOut1, SGFIn, null);
hr = pGraph.Connect(IPTOut1, SGFIn);
checkHR(hr, "Can't IPT1 to Sample In");
//hr = pGraph.ConnectDirect(SGFOut, NullIn, null);
hr = pGraph.Connect(SGFOut, NullIn);
checkHR(hr, "Can't Sample Out To Null In");
#endregion
IPin IPTOut2 = GetPin(InfinitePinTreeFilter, "Output2");
#endregion
#region Add Video Mixing Renderer9
//IBaseFilter pVideoMixingRenderer9 = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_VideoMixingRenderer9));
IBaseFilter pVideoMixingRenderer9 = (IBaseFilter)new VideoMixingRenderer9();
// Setup Video Renderer to go to Windows Form at this Point??
#region Setup WindowlessMode
IVMRFilterConfig9 MixingRendererFilterConfig = (IVMRFilterConfig9)pVideoMixingRenderer9;
hr = MixingRendererFilterConfig.SetNumberOfStreams(1);
checkHR(hr, "Problem Setting Streams to 1");

hr = MixingRendererFilterConfig.SetRenderingMode(VMR9Mode.Windowless);
checkHR(hr, "Can't Set Mode to Windowed"); // Doesn't work Windowless?

WindowlessControl = (IVMRWindowlessControl9)pVideoMixingRenderer9;
hr = WindowlessControl.SetVideoClippingWindow(VideoViewer.VideoPanel.Handle);
checkHR(hr, "Problem Setting Clipping Window to VideoPanel");

hr = WindowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
checkHR(hr, "Problem Setting Aspect Ration");
VideoViewer.AddHandlers();
VideoViewer.Visible = true;

#endregion
hr = pGraph.AddFilter(pVideoMixingRenderer9, "Video Mixing Renderer 9");
checkHR(hr, "Can't Create Video Mixing Renderer 9");
IPin VideoFormPin = GetPin(pVideoMixingRenderer9, "VMR Input0");
#endregion
#region Create AVI Decompressor
IBaseFilter pAVIDecompressor = (IBaseFilter)new AVIDec();
AMMediaType AVIInMedia = new AMMediaType();
AMMediaType AVIOutMedia = new AMMediaType();
AVIOutMedia.majorType = MediaType.Video;
AVIOutMedia.subType = MediaSubType.UYVY;
hr = pGraph.AddFilter(pAVIDecompressor, "AVI Decompressor");
checkHR(hr, "Can't add AVI Decompressor to graph");
// No Configuration needed for the AVI Decompresser that I know of
IPin AVIDecompressorOutPin = GetPin(pAVIDecompressor, "XForm Out");
IPin AVIDecompressorInPin = GetPin(pAVIDecompressor, "XForm In");
#endregion
#region Connect Infinite Pin Out2 to Input of AVI Decompressor
//hr = pGraph.ConnectDirect(IPTOut2, AVIDecompressorInPin, null);
hr = pGraph.Connect(IPTOut2, AVIDecompressorInPin);
checkHR(hr, "Can't Connect Infinite Pin 2 to AVI Decompressor");
#endregion
#region Connect Output of AVI Decompressor to Video Mixing Renderer9
//hr = pGraph.ConnectDirect(AVIDecompressorOutPin, VideoFormPin, null);
hr = pGraph.Connect(AVIDecompressorOutPin, VideoFormPin);
checkHR(hr, "Can't Connect AVI Out to Renderer");
#endregion
VideoViewer.Activate();
}


Return to posts index

Robert Huff
Re: Capture Resolution DirectShow
on Feb 18, 2011 at 10:25:17 pm

Got it.

IAMStreamConfig streamConfig = (IAMStreamConfig)VideoOutPin;
AMMediaType searchmedia;
AMMediaType CorectvidFormat = new AMMediaType();
IntPtr ptr;

int piCount, piSize;
hr = streamConfig.GetNumberOfCapabilities(out piCount, out piSize);
ptr = Marshal.AllocCoTaskMem(piSize);
for (int i = 0; i < piCount; i++)
{
hr = streamConfig.GetStreamCaps(i, out searchmedia, ptr);
VideoInfoHeader v = new VideoInfoHeader();
Marshal.PtrToStructure(searchmedia.formatPtr, v);
if (i == 6)
{
CorectvidFormat = searchmedia;
}
}
hr = streamConfig.SetFormat(CorectvidFormat);

Doesn't select it directly, but I need the 6th iteration. and now I'v no longer got a black screen.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]