From 5fb12a877656031f4bddc3d5280b6ff08977dffe Mon Sep 17 00:00:00 2001 From: ochibani <11yzyv86j@relay.firefox.com> Date: Mon, 17 Jun 2024 21:05:46 +0200 Subject: [PATCH] fix draw_mouse --- src/ffmpeg_interface.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index d5a225a..ea86743 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -87,9 +87,16 @@ impl Ffmpeg { if self.record_video.is_active() && !is_wayland() { 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 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()) .as_str(), x, @@ -101,19 +108,6 @@ impl Ffmpeg { 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 self.follow_mouse.is_active() { ffmpeg_command.args(["-follow_mouse", "centered"]); @@ -133,6 +127,7 @@ impl Ffmpeg { self.filename.2.active_id().unwrap() ); + // Output ffmpeg_command.args([ { if self.record_audio.is_active() {