-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenCaptureRecorder.cs
46 lines (39 loc) · 1.22 KB
/
ScreenCaptureRecorder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Drawing;
using System.Threading.Tasks;
using Xabe.FFmpeg;
using Xabe.FFmpeg.Streams;
namespace WpfApp32
{
internal class ScreenCaptureRecorder
{
public string OutputPath { get; internal set; }
public VideoCodec VideoCodec { get; internal set; }
public Rectangle CaptureRectangle { get; internal set; }
public async Task StartRecordingAsync()
{
IVideoStream videoStream = new Xabe.FFmpeg.Streams.VideoStream(OutputPath, VideoCodec.h264);
await FFmpeg.Conversions.New()
.AddInput($"-f gdigrab -framerate 30 -i desktop")
.AddStream(videoStream)
.Start();
}
public async Task StopRecordingAsync()
{
await Task.Delay(1000); // Delay 1 second to ensure the recording is stopped.
await FFmpeg.Conversions.New().StopRecordingAsync();
}
internal void Dispose()
{
throw new NotImplementedException();
}
internal void Start()
{
throw new NotImplementedException();
}
internal void Stop()
{
throw new NotImplementedException();
}
}
}