Note that there are some explanatory texts on larger screens.

plurals
  1. POSeeking keyframes using DirectShowNet
    primarykey
    data
    text
    <p>My task is : I create a graph, attach a SampleGrabber to it, and grab the keyframes using the IMediaSeeking interface after building the graph.</p> <p>The following is what I have done : In the Main method :</p> <pre><code> Type comType = Type.GetTypeFromCLSID ( new Guid ( "e436ebb3-524f-11ce-9f53-0020af0ba770" ) ); IGraphBuilder graphBuilder = (IGraphBuilder) Activator.CreateInstance ( comType ); comType = Type.GetTypeFromCLSID ( new Guid ( "C1F400A0-3F08-11d3-9F0B-006008039E37" ) ); ISampleGrabber sampleGrabber = (ISampleGrabber) Activator.CreateInstance ( comType ); graphBuilder.AddFilter ( (IBaseFilter) sampleGrabber, "samplegrabber" ); AMMediaType mediaType = new AMMediaType ( ); mediaType.majorType = MediaType.Video; mediaType.subType = MediaSubType.RGB24; mediaType.formatType = FormatType.VideoInfo; sampleGrabber.SetMediaType ( mediaType ); int hr = graphBuilder.RenderFile ( @"D:\test.wmv", null ); IMediaEventEx mediaEvent = (IMediaEventEx) graphBuilder; IMediaControl mediaControl = (IMediaControl) graphBuilder; IVideoWindow videoWindow = (IVideoWindow) graphBuilder; IBasicAudio basicAudio = (IBasicAudio) graphBuilder; videoWindow.put_AutoShow ( OABool.False ); basicAudio.put_Volume ( -10000 ); sampleGrabber.SetOneShot ( false ); sampleGrabber.SetBufferSamples ( true ); //the same object has implemented the ISampleGrabberCB interface. //0 sets the callback to the ISampleGrabberCB::SampleCB() method. sampleGrabber.SetCallback (this, 0); mediaControl.Run ( ); EventCode eventCode; mediaEvent.WaitForCompletion ( -1, out eventCode ); Marshal.ReleaseComObject ( sampleGrabber ); Marshal.ReleaseComObject ( graphBuilder ); </code></pre> <p>In the SampleCB() callback method :</p> <pre><code> public int SampleCB ( double sampleTime, IMediaSample mediaSample ) { Console.WriteLine ( "SampleCB Callback" ); Console.WriteLine ( mediaSample.IsSyncPoint ( ) + " " + mediaSample.GetActualDataLength() ); //check if its a keyframe using mediaSample.IsSyncPoint() //and convert the buffer into image and save it. return 0; } </code></pre> <p>Thus, I have set up the things. Now, when i run the program, everything loads correctly. But the callback is called only once, and then the rendering stops. No more rendering and no more callbacks. I had tried the another callback method ISampleGrabber::BufferCB() to see if it follows the same fate. But no! BufferCB() is called everytime a frame is grabbed and the video is rendered till the end.</p> <p>What am I doing wrong? Any suggestions on this? Thank you :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload