allow compiling out systemd-run support

This commit is contained in:
Dominic 2024-05-18 12:52:08 +02:00
parent 0d98ab21f0
commit 4612cbdfaa
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D
4 changed files with 37 additions and 18 deletions

View file

@ -105,8 +105,10 @@ impl FfmpegOutput {
const QUALITY: &str = "22";
if venc {
let vcodec = match (self.format, vaapi) {
(FfmpegOutputFormat::Av1Flac, false) | (FfmpegOutputFormat::Av1Opus, false) => "libsvtav1",
(FfmpegOutputFormat::Av1Flac, true) | (FfmpegOutputFormat::Av1Opus, true) => "av1_vaapi",
(FfmpegOutputFormat::Av1Flac, false)
| (FfmpegOutputFormat::Av1Opus, false) => "libsvtav1",
(FfmpegOutputFormat::Av1Flac, true)
| (FfmpegOutputFormat::Av1Opus, true) => "av1_vaapi",
(FfmpegOutputFormat::AvcAac, false) => "h264",
(FfmpegOutputFormat::AvcAac, true) => "h264_vaapi"
};

View file

@ -9,7 +9,7 @@ use crate::{
iotro::{intro, outro},
render::ffmpeg::{Ffmpeg, FfmpegInput},
time::{format_date, Time},
Project, ProjectSourceMetadata, Resolution, MEM_LIMIT
Project, ProjectSourceMetadata, Resolution
};
use anyhow::{bail, Context};
use camino::{Utf8Path as Path, Utf8PathBuf as PathBuf};
@ -39,18 +39,24 @@ const FF_LOGO_SIZE: usize = 128;
const LOGO_SIZE: usize = 96;
fn cmd() -> Command {
// 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={}", MEM_LIMIT.read().unwrap()))
.arg("--user");
// we use busybox ash for having a shell that outputs commands with -x
cmd.arg("busybox")
.arg("ash")
#[cfg(feature = "mem_limit")]
let mut cmd = {
// 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={}", crate::MEM_LIMIT.read().unwrap()))
.arg("--user");
// we use busybox ash for having a shell that outputs commands with -x
cmd.arg("busybox");
cmd
};
#[cfg(not(feature = "mem_limit"))]
let mut cmd = Command::new("busybox");
cmd.arg("ash")
.arg("-exuo")
.arg("pipefail")
.arg("-c")