Screen source
Screen source supports recording video from the screen. You can select the display (if more than one), the part of the screen to be recorded, and optional mouse cursor recording.
Settings
Windows
ScreenCaptureDX9SourceSettings
- UseDirectX 9
for screen recording.ScreenCaptureD3D11SourceSettings
- UseDirect3D 11
for screen recording.ScreenCaptureGDISourceSettings
- UseGDI
for screen recording.
macOS
ScreenCaptureMacOSSourceSettings
- Use AVFoundation
for screen recording.
Linux
ScreenCaptureXDisplaySourceSettings
- Use X11
for screen recording.
iOS
IOSScreenSourceSettings
- Use AVFoundation
for current window recording.
Block info
Name: ScreenSourceBlock.
Pin direction | Media type | Pins count |
---|---|---|
Output video | uncompressed video | 1 |
The sample pipeline
Sample code
// create pipeline
var pipeline = new MediaBlocksPipeline();
// create source settings
var screenSourceSettings = new ScreenCaptureDX9SourceSettings() { FrameRate = 15 }
// create source block
var screenSourceBlock = new ScreenSourceBlock(screenSourceSettings);
// create video encoder block and connect it to the source block
var h264EncoderBlock = new H264EncoderBlock(new MFH264EncoderSettings());
pipeline.Connect(screenSourceBlock.Output, h264EncoderBlock.Input);
// create MP4 sink block and connect it to the encoder block
var mp4SinkBlock = new MP4SinkBlock(new MP4SinkSettings(@"output.mp4"));
pipeline.Connect(h264EncoderBlock.Output, mp4SinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));
// run pipeline
await pipeline.StartAsync();
[Windows] Window capture
You can capture a specific window by using the ScreenCaptureD3D11SourceSettings
class.
// create Direct3D11 source
var source = new ScreenCaptureD3D11SourceSettings();
// set frame rate
source.FrameRate = new VideoFrameRate(30);
// get handle of the window
var wih = new System.Windows.Interop.WindowInteropHelper(this);
source.WindowHandle = wih.Handle;
// create source block
var screenSourceBlock = new ScreenSourceBlock(new ScreenCaptureDX9SourceSettings() { FrameRate = 15 });
// other code is the same as above
Sample applications
Platforms
Windows, macOS, Linux, iOS.