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

Error W11 home #244

Closed arogerm closed 1 year ago

arogerm commented 1 year ago

Dear All

with this code on W11 Home I get error, on W10 works fine

        string videoPath = Path.Combine(Path.GetTempPath(), "test.mp4");
        try
        {
            if (System.IO.File.Exists(videoPath))
                System.IO.File.Delete(videoPath);
        }
        catch { }
        RecorderOptions options = RecorderOptions.DefaultMainMonitor;
        VideoEncoderOptions xOpVideo = new VideoEncoderOptions
        {
            IsHardwareEncodingEnabled = false,
            IsThrottlingDisabled = false,
            IsLowLatencyEnabled = true,
            IsMp4FastStartEnabled = true,
            Quality = 50,
            Framerate = 8,
            IsFixedFramerate = true,
            Encoder = new H264VideoEncoder
            {
                BitrateMode = H264BitrateControlMode.Quality,
                EncoderProfile = H264Profile.Main,
            }
        };
        options.VideoEncoderOptions = xOpVideo;
        MouseOptions xMO = new MouseOptions
        {
            IsMouseClicksDetected = true,
            IsMousePointerEnabled = true,
        };
        options.MouseOptions = xMO;
        _rec = Recorder.CreateRecorder(options);
        _rec.OnRecordingComplete += Rec_OnRecordingComplete;
        _rec.OnRecordingFailed += Rec_OnRecordingFailed;
        _rec.OnStatusChanged += Rec_OnStatusChanged;
        //Record to a file
        _rec.Record(videoPath);

i get this error the system does not support the specified device interface or feature level

any ideas?

screenrecorderlib

sskodje commented 1 year ago

If it's a laptop with a dedicated + integrated graphics, it's possible it's because of an old bug in Desktop Duplication API on such systems. You can check by switching DisplayRecordingSource::RecorderApi property to WindowsGraphicsCapture. WindowsGraphicsCapture works better on modern OS like W11. On W11 you can also hide the yellow border if need with the IsBorderRequired property on the source.

arogerm commented 1 year ago

Sorry for my later respons I develop on c# There are any sample how to use DisplayRecordingSource?

sskodje commented 1 year ago

You can check the wiki https://github.com/sskodje/ScreenRecorderLib/wiki/Quickstart-guide-v5.x.x#select-source-to-record.