Skip to content

Commit 1b95a53

Browse files
committed
[rust] Change ffmpeg commands to record desktop in Linux and macOS
1 parent dc0c94d commit 1b95a53

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

rust/src/ffmpeg.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ const FFMPEG_LINUX_RELEASE_URL: &str = "https://github.com/BtbN/FFmpeg-Builds/re
4343
const FFMPEG_MACOS_RELEASE_URL: &str = "https://evermeet.cx/ffmpeg/ffmpeg-{}.zip";
4444
const FFMPEG_RECORD_FRAME_RATE: &str = "30";
4545
const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -q:v 1 -y {}";
46-
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -list_devices true";
47-
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = "{} -f avfoundation -list_devices true";
48-
// const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -q:v 1 -y {}";
49-
// const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
46+
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
47+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = r#"{} -f avfoundation -list_devices true -i """#;
5048
// const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = "{} -f avfoundation -i {} -r {} -y {}";
5149
const FFMPEG_RECORDING_EXTENSION: &str = "avi";
5250
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
@@ -219,19 +217,20 @@ pub fn record_desktop_with_ffmpeg(
219217
FFMPEG_RECORD_FRAME_RATE,
220218
&recording_name,
221219
))
222-
} else {
223-
//let env_display = env::var(ENV_DISPLAY).unwrap_or_default();
220+
} else if MACOS.is(os) {
224221
Command::new_single(format_one_arg(
225222
get_recording_command(os),
226223
&path_to_string(&ffmpeg_path),
227224
))
228-
// Command::new_single(format_four_args(
229-
// get_recording_command(os),
230-
// &path_to_string(&ffmpeg_path),
231-
// &env_display,
232-
// FFMPEG_RECORD_FRAME_RATE,
233-
// &recording_name,
234-
// ))
225+
} else {
226+
let env_display = env::var(ENV_DISPLAY).unwrap_or_default();
227+
Command::new_single(format_four_args(
228+
get_recording_command(os),
229+
&path_to_string(&ffmpeg_path),
230+
&env_display,
231+
FFMPEG_RECORD_FRAME_RATE,
232+
&recording_name,
233+
))
235234
};
236235
run_shell_command_with_log(log, os, command).unwrap();
237236
Ok(())

0 commit comments

Comments
 (0)