Skip to content

Commit e4fe13d

Browse files
committed
Revert "[rust] Change devices in macOS recording"
This reverts commit c67f281.
1 parent c67f281 commit e4fe13d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

rust/src/ffmpeg.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ 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 = r#"{} -f avfoundation -i "0:0" -r {} -y {}"#;
47+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str =
48+
r#"{} -f avfoundation -video_device_index 0 -r {} -y {}"#;
4849
const FFMPEG_RECORDING_EXTENSION_AVI: &str = "avi";
50+
const FFMPEG_RECORDING_EXTENSION_MKV: &str = "mkv";
4951
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
5052
const FFMPEG_DEFAULT_DISPLAY: &str = ":0";
5153

@@ -189,9 +191,14 @@ pub fn uncompress_ffmpeg(
189191
Ok(())
190192
}
191193

192-
fn get_recording_name() -> String {
194+
fn get_recording_name(os: &str) -> String {
193195
let now = chrono::Local::now();
194-
now.format("%Y-%m-%d_%H-%M-%S").to_string() + "." + FFMPEG_RECORDING_EXTENSION_AVI
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
195202
}
196203

197204
pub fn record_desktop_with_ffmpeg(
@@ -202,7 +209,7 @@ pub fn record_desktop_with_ffmpeg(
202209
) -> Result<(), Error> {
203210
let recording_target = cache_path
204211
.join(FFMPEG_RECORDING_FOLDER)
205-
.join(get_recording_name());
212+
.join(get_recording_name(os));
206213
let recording_name = path_to_string(&recording_target);
207214
create_parent_path_if_not_exists(&recording_target)?;
208215

rust/tests/record_tests.rs

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

0 commit comments

Comments
 (0)