app: add native rune client for record-daemon

Replaces the Vue/Tauri front end with a rune app that speaks the daemon's
existing IPC protocol: settings (general, recording, audio), match history
and game review with a scrubber, event markers and ffmpeg highlight export.
Includes tray icon, launch at login, single instance, toasts, a headless
snapshot path for checking screens, and a cargo-packager NSIS config.

Rune is pinned to 4ddf696b0f and its three patched crates are vendored under
app/vendor, since a dependency's [patch.crates-io] does not apply to the app.

The daemon's OBS bootstrap never reached its IPC server on this machine, so
the live check is a `--probe` command; the wire format is covered by tests.
This commit is contained in:
vhaudiquet committed 2026-11-15 21:53:44 +01:00
1 parent d712c4ea85
commit 0377141e4f
349 files changed
+142819

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
//! Clip export with ffmpeg, ported from `export_clip` and `export_clip_precise` in
//! `tauri-app/src-tauri/src/lib.rs`.
use std::path::PathBuf;
use ffmpeg_sidecar::command::{FfmpegCommand, ffmpeg_is_installed};
use ffmpeg_sidecar::download::auto_download;
use ffmpeg_sidecar::event::{FfmpegEvent, LogLevel};
use crate::daemon;
/// The clips folder beside the recordings.
pub fn clips_dir() -> PathBuf {
let dir = daemon::recordings_dir().join("clips");
let _ = std::fs::create_dir_all(&dir);
dir
}
/// Download the ffmpeg sidecar on first use.
pub fn ensure_ffmpeg() -> Result<(), String> {
if ffmpeg_is_installed() {
return Ok(());
}
auto_download().map_err(|e| format!("cannot download ffmpeg: {e}"))
}
/// Export `start..end` of `video`. Stream copy is fast and keyframe-aligned; `precise` re-encodes
/// with x264 for exact cuts.
pub fn export_clip(
video: &str,
start: f64,
end: f64,
output_name: &str,
precise: bool,
quality: &str,
) -> Result<String, String> {
ensure_ffmpeg()?;
if !PathBuf::from(video).exists() {
return Err(format!("video file not found: {video}"));
}
let output = clips_dir().join(format!("{}.mp4", sanitize(output_name)));
let duration = (end - start).max(0.0);
if duration <= 0.0 {
return Err("the clip has no length".into());
}
let mut command = FfmpegCommand::new();
command
.arg("-y")
.arg("-ss")
.arg(format!("{start:.3}"))
.arg("-i")
.arg(video)
.arg("-t")
.arg(format!("{duration:.3}"));
if precise {
let crf = match quality {
"low" => "28",
"high" => "18",
_ => "23",
};
command
.arg("-c:v")
.arg("libx264")
.arg("-crf")
.arg(crf)
.arg("-preset")
.arg("fast")
.arg("-c:a")
.arg("aac")
.arg("-b:a")
.arg("128k");
} else {
command
.arg("-c")
.arg("copy")
.arg("-avoid_negative_ts")
.arg("make_zero");
}
let iter = command
.arg(output.to_string_lossy().to_string())
.spawn()
.map_err(|e| format!("cannot start ffmpeg: {e}"))?
.iter()
.map_err(|e| format!("cannot read ffmpeg output: {e}"))?;
let mut errors = Vec::new();
for event in iter {
match event {
FfmpegEvent::Error(e) => errors.push(e),
FfmpegEvent::Log(LogLevel::Error, msg) => errors.push(msg),
_ => {}
}
}
let size = std::fs::metadata(&output).map(|m| m.len()).unwrap_or(0);
if size == 0 {
return Err(if errors.is_empty() {
"ffmpeg produced no output".to_string()
} else {
errors.join("; ")
});
}
Ok(output.display().to_string())
}
fn sanitize(name: &str) -> String {
name.chars()
.map(|c| {
if c.is_alphanumeric() || matches!(c, '-' | '_' | '.') {
c
} else {
'_'
}
})
.collect()
}