Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Calculates the Media Frame Rate. The Numerator and Denominator were obtained from IMFMediaType from the video file loaded locally by IMFSourceReader.
- var FrameRate = Math.Round((Numerator / Denominator)).
- //Calculates the delay that will be used to call the next sample. Video processing time is 8 to 11ms.
- var Delay = Math.Round((1000 - Video Sample Processing Time) / FrameRate) - 12.
- //Get the next video sample available in the buffer.
- IMFSample VideoSample = BufferVideo.Next();
- //Calls the method that will copy the read sample data to the IMFVideoSampleAllocator sample. The sample is accessed for the IMF2DBuffer2 interface as recommended by MSDN.
- ProcessVideoSample(VideoSample);
- //I call IMFSourceReader to read the next available video sample. This method is thread safe. The sample reader is in Asynchronous mode.
- RequestNextSample(TypeSample.Video);
- //Delay to read the next sample. The delay is calculated as shown above.
- await Task.Delay(DelayFrameRate);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement