Skip to content

Commit 1c77e7d

Browse files
committed
[rust] Use MKV format in macOS recording
1 parent 7b6414b commit 1c77e7d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.github/workflows/bazel.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,19 @@ jobs:
192192
uses: actions/upload-artifact@v4
193193
with:
194194
name: recordings-win
195-
path: C:\Users\runneradmin\.cache\selenium\recordings\*.avi
195+
path: C:\Users\runneradmin\.cache\selenium\recordings\*.*
196196
retention-days: 6
197197
- name: Save recordings (Linux)
198198
if: inputs.save-recordings && inputs.os == 'ubuntu'
199199
uses: actions/upload-artifact@v4
200200
with:
201201
name: recordings-linux
202-
path: /home/runner/.cache/selenium/recordings/*.avi
202+
path: /home/runner/.cache/selenium/recordings/*.*
203203
retention-days: 6
204204
- name: Save recordings (macOS)
205205
if: inputs.save-recordings && inputs.os == 'macos'
206206
uses: actions/upload-artifact@v4
207207
with:
208208
name: recordings-macos
209-
path: /Users/runner/.cache/selenium/recordings/*.avi
209+
path: /Users/runner/.cache/selenium/recordings/*.*
210210
retention-days: 6

rust/src/ffmpeg.rs

Lines changed: 12 additions & 5 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 -video_device_index 0 -r {} -y {}"#;
48-
const FFMPEG_RECORDING_EXTENSION: &str = "avi";
47+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str =
48+
r#"{} -f avfoundation -video_device_index 0 -r {} -y {}"#;
49+
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
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

0 commit comments

Comments
 (0)