diff --git a/interfaces/main.ui b/interfaces/main.ui index 231cabc..9f5155b 100644 --- a/interfaces/main.ui +++ b/interfaces/main.ui @@ -13,14 +13,14 @@ 2 - 1 - 200 + 0 + 240 1 10 - + 0 - 51 + 50000 1 10 @@ -478,7 +478,7 @@ - + True True label @@ -489,13 +489,13 @@ - + True True 2 2 number - adjustment-quality + adjustment-bitrate 1 True diff --git a/locales/ar.ftl b/locales/ar.ftl index e84bdb0..d53d56f 100644 --- a/locales/ar.ftl +++ b/locales/ar.ftl @@ -102,8 +102,8 @@ license = لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }. -# Quality label -quality = الجودة: +# Bitrate label +bitrate = معدل البت: # Recording button record = سجل @@ -146,7 +146,7 @@ format-tooltip = لاختيار صيغة الخَرج frames-tooltip = عدد الإطارات في الثانية hide-tooltip = لإخفاء نافذة المسجل الأزرق عند بدء التسجيل mouse-tooltip = يظهر مؤشر الفأرة عند التسجيل -quality-tooltip = جودة التسجيل (CRF) +bitrate-tooltip = ضبط معدل البت بوحدة KB record-tooltip = يبدأ تسجيل الشاشة screen-tooltip = يحدد الشاشة ليسجلها speaker-tooltip = يسجل باستخدام مخرج الصوت diff --git a/locales/ar_YE.ftl b/locales/ar_YE.ftl index e84bdb0..d53d56f 100644 --- a/locales/ar_YE.ftl +++ b/locales/ar_YE.ftl @@ -102,8 +102,8 @@ license = لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }. -# Quality label -quality = الجودة: +# Bitrate label +bitrate = معدل البت: # Recording button record = سجل @@ -146,7 +146,7 @@ format-tooltip = لاختيار صيغة الخَرج frames-tooltip = عدد الإطارات في الثانية hide-tooltip = لإخفاء نافذة المسجل الأزرق عند بدء التسجيل mouse-tooltip = يظهر مؤشر الفأرة عند التسجيل -quality-tooltip = جودة التسجيل (CRF) +bitrate-tooltip = ضبط معدل البت بوحدة KB record-tooltip = يبدأ تسجيل الشاشة screen-tooltip = يحدد الشاشة ليسجلها speaker-tooltip = يسجل باستخدام مخرج الصوت diff --git a/locales/en.ftl b/locales/en.ftl index 4091498..b134997 100644 --- a/locales/en.ftl +++ b/locales/en.ftl @@ -99,8 +99,8 @@ license = Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }. -# Quality label -quality = Quality: +# Bitrate label +bitrate = Bitrate: # Recording button record = Record @@ -143,7 +143,7 @@ format-tooltip = Select file format frames-tooltip = Frames rate hide-tooltip = Hide window when start recording mouse-tooltip = Mouse appears in video recording -quality-tooltip = Video quality (CRF) +bitrate-tooltip = Set video bitrate in KB record-tooltip = Start screen record screen-tooltip = Select screen to record speaker-tooltip = Speakr sound recording diff --git a/locales/en_US.ftl b/locales/en_US.ftl index 4091498..b134997 100644 --- a/locales/en_US.ftl +++ b/locales/en_US.ftl @@ -99,8 +99,8 @@ license = Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }. -# Quality label -quality = Quality: +# Bitrate label +bitrate = Bitrate: # Recording button record = Record @@ -143,7 +143,7 @@ format-tooltip = Select file format frames-tooltip = Frames rate hide-tooltip = Hide window when start recording mouse-tooltip = Mouse appears in video recording -quality-tooltip = Video quality (CRF) +bitrate-tooltip = Set video bitrate in KB record-tooltip = Start screen record screen-tooltip = Select screen to record speaker-tooltip = Speakr sound recording diff --git a/src/config_management.rs b/src/config_management.rs index b1b81e4..1be465a 100755 --- a/src/config_management.rs +++ b/src/config_management.rs @@ -28,9 +28,9 @@ pub fn initialize() -> PathBuf { fn default() { for format in 0..7 { - set_default_quality(&format.to_string()); + set_default_bitrate(&format.to_string()); + set_default_frame(&format.to_string()); } - set("default", "frame", "60"); set("default", "delay", "0"); set("default", "format", "0"); set( @@ -131,16 +131,30 @@ pub fn folder_icon(folder_chooser_name: Option<&str>) -> &str { } } -pub fn set_default_quality(format: &str) -> bool { - let crf = match format { - "0" => self::set("default", "quality-0", "23"), - "1" => self::set("default", "quality-1", "23"), - "2" => self::set("default", "quality-2", "10"), - "3" => self::set("default", "quality-3", "23"), - "4" => self::set("default", "quality-4", "23"), - "5" => self::set("default", "quality-5", "23"), - "6" => self::set("default", "quality-6", "23"), - _ => self::set("default", "quality-0", "23"), // Default value +pub fn set_default_bitrate(format: &str) -> bool { + let rate = match format { + "0" => self::set("default", "bitrate-0", "0"), + "1" => self::set("default", "bitrate-1", "0"), + "2" => self::set("default", "bitrate-2", "0"), + "3" => self::set("default", "bitrate-3", "0"), + "4" => self::set("default", "bitrate-4", "0"), + "5" => self::set("default", "bitrate-5", "0"), + "6" => self::set("default", "bitrate-6", "0"), + _ => self::set("default", "bitrate-0", "0"), // Default value }; - crf + rate +} + +pub fn set_default_frame(format: &str) -> bool { + let rate = match format { + "0" => self::set("default", "frame-0", "60"), + "1" => self::set("default", "frame-1", "60"), + "2" => self::set("default", "frame-2", "60"), + "3" => self::set("default", "frame-3", "60"), + "4" => self::set("default", "frame-4", "60"), + "5" => self::set("default", "frame-5", "60"), + "6" => self::set("default", "frame-6", "60"), + _ => self::set("default", "frame-0", "60"), // Default value + }; + rate } diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 8c8e73b..d5a225a 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -38,7 +38,7 @@ pub struct Ffmpeg { pub main_context: gtk::glib::MainContext, pub temp_video_filename: String, pub bundle: String, - pub record_quality: SpinButton, + pub record_bitrate: SpinButton, } impl Ffmpeg { @@ -89,7 +89,6 @@ impl Ffmpeg { // record video with specified width and hight ffmpeg_command.size(width.into(), height.into()) - .rate(self.record_frames.value() as f32) .format("x11grab") .input(format!("{}+{},{}", std::env::var("DISPLAY").unwrap_or_else(|_| ":0".to_string()) .as_str(), @@ -97,12 +96,22 @@ impl Ffmpeg { y )); + // Disable frame rate if value is zero + if self.record_frames.value() > 0.0 { + ffmpeg_command.rate(self.record_frames.value() as f32); + } + // if show mouse switch is enabled, draw the mouse to video - ffmpeg_command.arg("-draw_mouse"); if self.record_mouse.is_active() { - ffmpeg_command.arg("1"); + ffmpeg_command.args([ + "-draw_mouse", + "1", + ]); } else { - ffmpeg_command.arg("0"); + ffmpeg_command.args([ + "-draw_mouse", + "0", + ]); } // if follow mouse switch is enabled, follow the mouse @@ -110,13 +119,20 @@ impl Ffmpeg { ffmpeg_command.args(["-follow_mouse", "centered"]); } + // Disable bitrate if value is zero + if self.record_bitrate.value() > 0.0 { + ffmpeg_command.args([ + "-b:v", + &format!("{}K", self.record_bitrate.value()), + ]); + } + let video_filename = format!( "{}.temp.without.audio.{}", self.saved_filename.as_ref().unwrap(), self.filename.2.active_id().unwrap() ); - ffmpeg_command.crf(self.record_quality.value() as u32); ffmpeg_command.args([ { if self.record_audio.is_active() { @@ -227,14 +243,20 @@ impl Ffmpeg { if is_wayland() { // convert webm to specified format let mut ffmpeg_command = FfmpegCommand::new(); - ffmpeg_command.input(self.temp_video_filename.as_str()) - .crf(self.record_quality.value() as u32) - .args([ - "-c:a", - self.filename.2.active_id().unwrap().as_str(), - self.saved_filename.as_ref().unwrap(), - ]).overwrite().spawn() - .unwrap().wait().unwrap(); + ffmpeg_command.input(self.temp_video_filename.as_str()); + if self.record_bitrate.value() > 0.0 { + ffmpeg_command.args([ + "-b:v", + &format!("{}K", self.record_bitrate.value()), + ]); + } + ffmpeg_command.args([ + "-c:a", + self.filename.2.active_id().unwrap().as_str(), + self.saved_filename.as_ref().unwrap(), + ]).overwrite() + .spawn() + .unwrap().wait().unwrap(); } else { let mut move_command = Command::new("mv"); move_command.args([ @@ -253,7 +275,6 @@ impl Ffmpeg { FfmpegCommand::new().input(video_filename.as_str()) .format("ogg") .input(audio_filename.as_str()) - .crf(self.record_quality.value() as u32) .args([ "-c:a", "aac", diff --git a/src/main.rs b/src/main.rs index 037eaf3..6a36dc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,8 +112,8 @@ pub fn build_ui(application: &Application) { let main_window: Window = builder.object("main_window").unwrap(); let mouse_switch: CheckButton = builder.object("mouseswitch").unwrap(); let play_button: Button = builder.object("playbutton").unwrap(); - let quality_label: Label = builder.object("quality_label").unwrap(); - let quality_spin: SpinButton = builder.object("quality").unwrap(); + let bitrate_label: Label = builder.object("bitrate_label").unwrap(); + let bitrate_spin: SpinButton = builder.object("bitrate").unwrap(); let record_button: Button = builder.object("recordbutton").unwrap(); let record_label: Label = builder.object("record_label").unwrap(); let record_time_label: Label = builder.object("record_time_label").unwrap(); @@ -395,10 +395,13 @@ pub fn build_ui(application: &Application) { .value().unwrap(), None, &mut vec![]).to_string())); delay_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("delay-tooltip").unwrap() .value().unwrap(), None, &mut vec![]).to_string())); - quality_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("quality-tooltip").unwrap() + bitrate_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("bitrate-tooltip").unwrap() .value().unwrap(), None, &mut vec![]).to_string())); frames_spin.set_value( - config_management::get("default", "frame") + config_management::get("default", + &format! + ("frame-{}", + &format_chooser_combobox.active().unwrap().to_string())) .parse::() .unwrap(), ); @@ -407,17 +410,18 @@ pub fn build_ui(application: &Application) { .parse::() .unwrap(), ); - quality_spin.set_value( + bitrate_spin.set_value( config_management::get("default", &format! - ("quality-{}", + ("bitrate-{}", &format_chooser_combobox.active().unwrap().to_string())) .parse::() .unwrap(), ); let _format_chooser_combobox = format_chooser_combobox.clone(); - let _quality_spin = quality_spin.clone(); + let _frames_spin = frames_spin.clone(); + let _bitrate_spin = bitrate_spin.clone(); format_chooser_combobox.connect_changed(move |_| { let format_chooser_combobox = _format_chooser_combobox.clone(); if _format_chooser_combobox.active_text().is_some() { @@ -426,10 +430,18 @@ pub fn build_ui(application: &Application) { "format", &_format_chooser_combobox.active().unwrap().to_string(), ); - _quality_spin.set_value( + _frames_spin.set_value( config_management::get("default", &format! - ("quality-{}", + ("frame-{}", + &format_chooser_combobox.active().unwrap().to_string())) + .parse::() + .unwrap(), + ); + _bitrate_spin.set_value( + config_management::get("default", + &format! + ("bitrate-{}", &format_chooser_combobox.active().unwrap().to_string())) .parse::() .unwrap(), @@ -438,12 +450,13 @@ pub fn build_ui(application: &Application) { }); let _frames_spin = frames_spin.to_owned(); + let _format_chooser_combobox = format_chooser_combobox.clone(); frames_spin.connect_value_changed(move |_| { - config_management::set( - "default", - "frame", - _frames_spin.value().to_string().as_str(), - ); + config_management::set("default", + &format! + ("frame-{}", + &_format_chooser_combobox.active().unwrap().to_string()), + _frames_spin.value().to_string().as_str()); }); let _delay_spin = delay_spin.to_owned(); delay_spin.connect_value_changed(move |_| { @@ -451,14 +464,14 @@ pub fn build_ui(application: &Application) { "delay", _delay_spin.value().to_string().as_str()); }); - let _quality_spin = quality_spin.to_owned(); + let _bitrate_spin = bitrate_spin.to_owned(); let _format_chooser_combobox = format_chooser_combobox.clone(); - quality_spin.connect_value_changed(move |_| { + bitrate_spin.connect_value_changed(move |_| { config_management::set("default", &format! - ("quality-{}", + ("bitrate-{}", &_format_chooser_combobox.active().unwrap().to_string()), - _quality_spin.value().to_string().as_str()); + _bitrate_spin.value().to_string().as_str()); }); // Labels @@ -468,7 +481,7 @@ pub fn build_ui(application: &Application) { .value().unwrap(), None, &mut vec![]).to_string()); delay_label.set_label(&bundle.format_pattern(bundle.get_message("delay").unwrap() .value().unwrap(), None, &mut vec![]).to_string()); - quality_label.set_label(&bundle.format_pattern(bundle.get_message("quality").unwrap() + bitrate_label.set_label(&bundle.format_pattern(bundle.get_message("bitrate").unwrap() .value().unwrap(), None, &mut vec![]).to_string()); audio_source_label.set_label(&bundle.format_pattern(bundle.get_message("audio-source").unwrap() .value().unwrap(), None, &mut vec![]).to_string()); @@ -607,7 +620,7 @@ pub fn build_ui(application: &Application) { main_context, temp_video_filename: String::new(), bundle: bundle_msg, - record_quality: quality_spin, + record_bitrate: bitrate_spin, })); // Record Button