limit the ram usage of ffmpeg
This commit is contained in:
parent
164bb8faa3
commit
2a8ba70e23
1 changed files with 14 additions and 2 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue