Skip to main content

Video sample grabber

The video sample grabber calls an event for each video frame. You can save or process the received video frame.

Block info

Name: VideoSampleGrabberBlock.

Pin directionMedia typePins count
InputUncompressed video1
OutputUncompressed video1

The sample pipeline

Sample code

var pipeline = new MediaBlocksPipeline();

var filename = "test.mp4";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));

var videoSG = new VideoSampleGrabberBlock();
videoSG.OnVideoFrameBuffer += VideoSG_OnVideoFrameBuffer;
pipeline.Connect(fileSource.VideoOutput, videoSG.Input);

var videoRenderer = new VideoRendererBlock(pipeline, VideoView1);
pipeline.Connect(videoSG.Output, videoRenderer.Input);

await pipeline.StartAsync();

private void VideoSG_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e)
{
// save or process the video frame
}

Platforms

Windows, macOS, Linux, iOS, Android.