Skip to content

Commit c67f281

Browse files
committed
[rust] Change devices in macOS recording
1 parent 1c77e7d commit c67f281

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

rust/src/ffmpeg.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ 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 {}";
4646
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
47-
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str =
48-
r#"{} -f avfoundation -video_device_index 0 -r {} -y {}"#;
47+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = r#"{} -f avfoundation -i "0:0" -r {} -y {}"#;
4948
const FFMPEG_RECORDING_EXTENSION_AVI: &str = "avi";
50-
const FFMPEG_RECORDING_EXTENSION_MKV: &str = "mkv";
5149
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
5250
const FFMPEG_DEFAULT_DISPLAY: &str = ":0";
5351

@@ -191,14 +189,9 @@ pub fn uncompress_ffmpeg(
191189
Ok(())
192190
}
193191

194-
fn get_recording_name(os: &str) -> String {
192+
fn get_recording_name() -> String {
195193
let now = chrono::Local::now();
196-
let extension = if MACOS.is(os) {
197-
FFMPEG_RECORDING_EXTENSION_MKV
198-
} else {
199-
FFMPEG_RECORDING_EXTENSION_AVI
200-
};
201-
now.format("%Y-%m-%d_%H-%M-%S").to_string() + "." + extension
194+
now.format("%Y-%m-%d_%H-%M-%S").to_string() + "." + FFMPEG_RECORDING_EXTENSION_AVI
202195
}
203196

204197
pub fn record_desktop_with_ffmpeg(
@@ -209,7 +202,7 @@ pub fn record_desktop_with_ffmpeg(
209202
) -> Result<(), Error> {
210203
let recording_target = cache_path
211204
.join(FFMPEG_RECORDING_FOLDER)
212-
.join(get_recording_name(os));
205+
.join(get_recording_name());
213206
let recording_name = path_to_string(&recording_target);
214207
create_parent_path_if_not_exists(&recording_target)?;
215208

rust/tests/record_tests.rs

-1
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)