Skip to content

Commit 2aa491b

Browse files
committed
[Use] Use device 0 and yuv420p mov for avfoundation recording (macOS)
1 parent e4fe13d commit 2aa491b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

rust/src/ffmpeg.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ const FFMPEG_RECORD_FRAME_RATE: &str = "30";
4545
const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -q:v 1 -y {}";
4646
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
4747
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str =
48-
r#"{} -f avfoundation -video_device_index 0 -r {} -y {}"#;
48+
r#"{} -f avfoundation -i 0 -r {} -pix_fmt yuv420p -y {}"#;
4949
const FFMPEG_RECORDING_EXTENSION_AVI: &str = "avi";
50-
const FFMPEG_RECORDING_EXTENSION_MKV: &str = "mkv";
50+
const FFMPEG_RECORDING_EXTENSION_MOV: &str = "mov";
5151
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
5252
const FFMPEG_DEFAULT_DISPLAY: &str = ":0";
5353

@@ -194,7 +194,7 @@ pub fn uncompress_ffmpeg(
194194
fn get_recording_name(os: &str) -> String {
195195
let now = chrono::Local::now();
196196
let extension = if MACOS.is(os) {
197-
FFMPEG_RECORDING_EXTENSION_MKV
197+
FFMPEG_RECORDING_EXTENSION_MOV
198198
} else {
199199
FFMPEG_RECORDING_EXTENSION_AVI
200200
};
@@ -218,7 +218,14 @@ pub fn record_desktop_with_ffmpeg(
218218
FFMPEG_NAME, &recording_name
219219
));
220220
let command = if LINUX.is(os) {
221-
let env_display = env::var(ENV_DISPLAY).unwrap_or(FFMPEG_DEFAULT_DISPLAY.to_string());
221+
let mut env_display = env::var(ENV_DISPLAY).unwrap_or_default();
222+
if env_display.is_empty() {
223+
log.warn(format!(
224+
"The env {} is empty. Using default value {}",
225+
ENV_DISPLAY, FFMPEG_DEFAULT_DISPLAY
226+
));
227+
env_display = FFMPEG_DEFAULT_DISPLAY.to_string();
228+
}
222229
Command::new_single(format_four_args(
223230
get_recording_command(os),
224231
&path_to_string(&ffmpeg_path),

rust/tests/record_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ fn test_record() {
4545
}
4646
};
4747
println!("Recording test status code: {:?}", status_code);
48-
panic!("Forced error");
4948
}

0 commit comments

Comments
 (0)