Skip to content
Snippets Groups Projects
Unverified Commit 2a8ba70e authored by Dominic Meiser's avatar Dominic Meiser
Browse files

limit the ram usage of ffmpeg

parent 164bb8fa
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@ use std::{
process::{Command, Stdio}
};
const MEMORY_LIMIT: &str = "2G";
const INTRO_LEN: Time = Time {
seconds: 3,
micros: 0
......@@ -39,8 +41,18 @@ const FF_LOGO_SIZE: usize = 128;
const LOGO_SIZE: usize = 96;
fn cmd() -> Command {
let mut cmd = Command::new("busybox");
cmd.arg("ash")
// we use systemd-run to limit the process memory
// I tried others like ulimit, chpst or isolate, but none worked
let mut cmd = Command::new("systemd-run");
cmd.arg("--scope")
.arg("-q")
.arg("--expand-environment=no")
.arg("-p")
.arg(format!("MemoryMax={MEMORY_LIMIT}"))
.arg("--user");
// we use busybox ash for having a shell that outputs commands with -x
cmd.arg("busybox")
.arg("ash")
.arg("-exuo")
.arg("pipefail")
.arg("-c")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment