Skip to content

Commit 7cd6f33

Browse files
committed
[rust] Use mkv as video container for all recordings
1 parent 0a4d944 commit 7cd6f33

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

rust/src/ffmpeg.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ const FFMPEG_WINDOWS_RELEASE_URL: &str =
3939
const FFMPEG_LINUX_RELEASE_URL: &str = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n{}-latest-linux64-gpl-{}.tar.xz";
4040
const FFMPEG_MACOS_RELEASE_URL: &str = "https://evermeet.cx/ffmpeg/ffmpeg-{}.zip";
4141
const FFMPEG_RECORD_FRAME_RATE: &str = "30";
42-
const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -q:v 1 -y {}";
43-
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
44-
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str =
45-
r#"{} -f avfoundation -i 0 -r {} -pix_fmt yuv420p -y {}"#;
46-
const FFMPEG_RECORDING_EXTENSION_AVI: &str = "avi";
47-
const FFMPEG_RECORDING_EXTENSION_MOV: &str = "mov";
42+
const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -y {}";
43+
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -y {}";
44+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = r#"{} -f avfoundation -i 0 -r {} -y {}"#;
45+
const FFMPEG_RECORDING_EXTENSION_MKV: &str = "mkv";
4846
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
4947
const FFMPEG_DEFAULT_DISPLAY: &str = ":0";
5048

@@ -183,14 +181,9 @@ pub fn uncompress_ffmpeg(
183181
Ok(())
184182
}
185183

186-
fn get_recording_name(os: &str) -> String {
184+
fn get_recording_name() -> String {
187185
let now = chrono::Local::now();
188-
let extension = if MACOS.is(os) {
189-
FFMPEG_RECORDING_EXTENSION_MOV
190-
} else {
191-
FFMPEG_RECORDING_EXTENSION_AVI
192-
};
193-
now.format("%Y-%m-%d_%H-%M-%S").to_string() + "." + extension
186+
now.format("%Y-%m-%d_%H-%M-%S").to_string() + "." + FFMPEG_RECORDING_EXTENSION_MKV
194187
}
195188

196189
pub fn record_desktop_with_ffmpeg(
@@ -201,7 +194,7 @@ pub fn record_desktop_with_ffmpeg(
201194
) -> Result<(), Error> {
202195
let recording_target = cache_path
203196
.join(FFMPEG_RECORDING_FOLDER)
204-
.join(get_recording_name(os));
197+
.join(get_recording_name());
205198
let recording_name = path_to_string(&recording_target);
206199
create_parent_path_if_not_exists(&recording_target)?;
207200

0 commit comments

Comments
 (0)