fix draw_mouse

This commit is contained in:
ochibani 2024-06-17 21:05:46 +02:00
parent 31567745f5
commit 5fb12a8776
No known key found for this signature in database
GPG Key ID: 2C6B61CE0C704ED4

View File

@ -87,9 +87,16 @@ impl Ffmpeg {
if self.record_video.is_active() && !is_wayland() { if self.record_video.is_active() && !is_wayland() {
let mut ffmpeg_command = FfmpegCommand::new(); let mut ffmpeg_command = FfmpegCommand::new();
// if show mouse switch is enabled, draw the mouse to video
let draw_mouse = if self.record_mouse.is_active() {
"-draw_mouse 1"
} else {
"-draw_mouse 0"
};
// record video with specified width and hight // record video with specified width and hight
ffmpeg_command.size(width.into(), height.into()) ffmpeg_command.size(width.into(), height.into())
.format("x11grab") .format("x11grab").args(draw_mouse.split(' '))
.input(format!("{}+{},{}", std::env::var("DISPLAY").unwrap_or_else(|_| ":0".to_string()) .input(format!("{}+{},{}", std::env::var("DISPLAY").unwrap_or_else(|_| ":0".to_string())
.as_str(), .as_str(),
x, x,
@ -101,19 +108,6 @@ impl Ffmpeg {
ffmpeg_command.rate(self.record_frames.value() as f32); ffmpeg_command.rate(self.record_frames.value() as f32);
} }
// if show mouse switch is enabled, draw the mouse to video
if self.record_mouse.is_active() {
ffmpeg_command.args([
"-draw_mouse",
"1",
]);
} else {
ffmpeg_command.args([
"-draw_mouse",
"0",
]);
}
// if follow mouse switch is enabled, follow the mouse // if follow mouse switch is enabled, follow the mouse
if self.follow_mouse.is_active() { if self.follow_mouse.is_active() {
ffmpeg_command.args(["-follow_mouse", "centered"]); ffmpeg_command.args(["-follow_mouse", "centered"]);
@ -133,6 +127,7 @@ impl Ffmpeg {
self.filename.2.active_id().unwrap() self.filename.2.active_id().unwrap()
); );
// Output
ffmpeg_command.args([ ffmpeg_command.args([
{ {
if self.record_audio.is_active() { if self.record_audio.is_active() {