From 2b89161c9239bd7ca8be815687adc053cb26c548 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Sat, 27 Nov 2021 05:10:48 +0300 Subject: [PATCH] upgrade zbus and zvariant --- Cargo.toml | 4 ++-- src/ffmpeg_interface.rs | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b1fa8d7..5ec6ce1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ chrono = "0.4.19" libappindicator = "0.5.2" gettext-rs = "0.7.0" subprocess = "0.2.6" -zbus = "1.8.0" -zvariant = "2.3.0" +zbus = "1.9.2" +zvariant = "2.10.0" gdk-pixbuf = "0.9.0" [dependencies.gtk] diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index ed14a11..e312f76 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -126,7 +126,7 @@ impl Ffmpeg { .join(PathBuf::from(format!( "{}.{}", if self.filename.1.get_text().to_string().trim().eq("") { - Utc::now().to_string().replace(" UTC", "") + Utc::now().to_string().replace(" UTC", "").replace(" ", "-") } else { self.filename.1.get_text().to_string().trim().to_string() }, @@ -180,18 +180,6 @@ impl Ffmpeg { // record video with specified width and hight ffmpeg_command.arg("-video_size"); ffmpeg_command.arg(format!("{}x{}", width, height)); - // if show mouse switch is enabled, draw the mouse to video - ffmpeg_command.arg("-draw_mouse"); - if self.record_mouse.get_active() { - ffmpeg_command.arg("1"); - } else { - ffmpeg_command.arg("0"); - } - // if follow mouse switch is enabled, follow the mouse - if self.follow_mouse.get_active() { - ffmpeg_command.arg("-follow_mouse"); - ffmpeg_command.arg("centered"); - } ffmpeg_command.arg("-framerate"); ffmpeg_command.arg(format!("{}", self.record_frames.get_value())); ffmpeg_command.arg("-f"); @@ -200,12 +188,27 @@ impl Ffmpeg { ffmpeg_command.arg(format!( "{}+{},{}", std::env::var("DISPLAY") - .unwrap_or(":1".to_string()) + .unwrap_or(":0".to_string()) .as_str(), x, y )); - ffmpeg_command.arg("-q"); + + // if show mouse switch is enabled, draw the mouse to video + ffmpeg_command.arg("-draw_mouse"); + if self.record_mouse.get_active() { + ffmpeg_command.arg("1"); + } else { + ffmpeg_command.arg("0"); + } + + // if follow mouse switch is enabled, follow the mouse + if self.follow_mouse.get_active() { + ffmpeg_command.arg("-follow_mouse"); + ffmpeg_command.arg("centered"); + } + + ffmpeg_command.arg("-crf"); ffmpeg_command.arg("1"); ffmpeg_command.arg(self.saved_filename.as_ref().unwrap().to_string()); ffmpeg_command.arg("-y"); @@ -419,7 +422,6 @@ impl Ffmpeg { // make unbound channel for communication with record thread let (tx, tr): (Sender, Receiver) = mpsc::channel(); self.unbound = Some(tx); - let receiver: Receiver = tr; // start recording in another thread std::thread::spawn(move || { @@ -435,7 +437,7 @@ impl Ffmpeg { .unwrap(); loop { - if receiver.recv().unwrap_or(false) { + if tr.recv().unwrap_or(false) { break; } }