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
414 stars 94 forks source link

Feature Request: Can we use this library to only record audio from mic & speaker? #279

Closed ranwer-dev closed 4 months ago

ranwer-dev commented 10 months ago

Can this library be modified in a way that it supports only audio recording? I mean no screen recording, just output the audio from the mic & speaker.

sskodje commented 10 months ago

You can turn off the video input, but it will be a black screen video with audio, not an audio file.

Willy-Kimura commented 9 months ago

Looks like the OutputOptions.IsVideoCaptureEnabled property is not working.

Edit

You'll need to also disable any added DisplayRecordingSource from your RecordingSourceBase list. Example:

var sources = new List<RecordingSourceBase>();

// Add your default screen for example.
var monitor = new DisplayRecordingSource(Screen.PrimaryScreen.DeviceName);

// Disable video capture here...
monitor.IsVideoCaptureEnabled = false;

sources.Add(monitor);

// Define your recording options, including the output options.
// Take note of the prop "IsVideoCaptureEnabled = false" here.
RecorderOptions audioOptions = new RecorderOptions
{
    SourceOptions = new SourceOptions
    {
        RecordingSources = sources
    },
    OutputOptions = new OutputOptions
    {
        IsVideoCaptureEnabled = false
    }
};
rwedoff commented 7 months ago

Also note, Overlay options shouldn't be set then as well.