sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
408 stars 93 forks source link

Recording the secondary screen #264

Closed HPBotma closed 11 months ago

HPBotma commented 11 months ago

Hi - I can't seem to get the library to record the second screen? [Screen connected to my laptop via HDMI].

It records the primary screen fine, but if I select only the second screen for recording - it throws an exception "The parameter is incorrect".

If I choose to record both screens simultaneously, I get no errors, but on playback, there is a blank spot where the second display should be.

i use the snippet from the example project to configure the sources: RecorderOptions options = new RecorderOptions { SourceOptions = new SourceOptions { RecordingSources = sources } }; _rec = Recorder.CreateRecorder(options);

screenlib issue

Not sure why the second screen is called display 4 [see image] - as there is nothing else connected? Any advice would be greatly appreciated

sskodje commented 11 months ago

Does it work if you swap the recorder API from Desktop Duplication to Windows Graphics Capture? Desktop duplication is older, and have known issues with laptops with both integrated graphics and discrete graphics.

HPBotma commented 11 months ago

Thanks for the quick response! However, I am not sure where to change the recorder API ? the example project does not seem to make any mention of it?

sskodje commented 11 months ago

It's the property RecorderApi on the DisplayRecordingSource object. Edit: On the sample project, you can select it on a dropdown next to the monitor name and path.

HPBotma commented 11 months ago

Great - works well! Thanks for all the effort in creating and maintaining this library

kasirajansfm commented 4 months ago

SourceOptions = new SourceOptions { RecordingSources = { new DisplayRecordingSource { DeviceName = DisplayRecordingSource.MainMonitor.DeviceName,RecorderApi = RecorderApi.WindowsGraphicsCapture } } },

added this option but still records main monitor only, anyone facing same?