This commit is contained in:
ochibani 2024-06-17 02:48:58 +02:00
parent 68aea8349f
commit 31567745f5
No known key found for this signature in database
GPG Key ID: 2C6B61CE0C704ED4
8 changed files with 115 additions and 67 deletions

View File

@ -13,14 +13,14 @@
<property name="page-increment">2</property>
</object>
<object class="GtkAdjustment" id="adjustment-frames">
<property name="lower">1</property>
<property name="upper">200</property>
<property name="lower">0</property>
<property name="upper">240</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment-quality">
<object class="GtkAdjustment" id="adjustment-bitrate">
<property name="lower">0</property>
<property name="upper">51</property>
<property name="upper">50000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
@ -478,7 +478,7 @@
</object>
</child>
<child>
<object class="GtkLabel" id="quality_label">
<object class="GtkLabel" id="bitrate_label">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="label" translatable="yes">label</property>
@ -489,13 +489,13 @@
</object>
</child>
<child>
<object class="GtkSpinButton" id="quality">
<object class="GtkSpinButton" id="bitrate">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="max-width-chars">2</property>
<property name="width-chars">2</property>
<property name="text">number</property>
<property name="adjustment">adjustment-quality</property>
<property name="adjustment">adjustment-bitrate</property>
<property name="climb-rate">1</property>
<property name="has-tooltip">True</property>
<layout>

View File

@ -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 = يسجل باستخدام مخرج الصوت

View File

@ -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 = يسجل باستخدام مخرج الصوت

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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,13 +243,19 @@ 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([
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()
]).overwrite()
.spawn()
.unwrap().wait().unwrap();
} else {
let mut move_command = Command::new("mv");
@ -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",

View File

@ -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::<f64>()
.unwrap(),
);
@ -407,17 +410,18 @@ pub fn build_ui(application: &Application) {
.parse::<f64>()
.unwrap(),
);
quality_spin.set_value(
bitrate_spin.set_value(
config_management::get("default",
&format!
("quality-{}",
("bitrate-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.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::<f64>()
.unwrap(),
);
_bitrate_spin.set_value(
config_management::get("default",
&format!
("bitrate-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.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