fix: ffmpeg version detection and player letterboxing

ffmpeg only accepts -version (single dash); it exits 8 on --version and
writes to stderr, so the status panel reported it missing even when
installed. Version flags are now per-tool and both streams are read.

The player used max-h-full inside a grid, which a 1080x1920 Short
overflowed. Switched to absolute fill with object-contain so portrait
and landscape both letterbox correctly.

Also sized the window to 1180x780 centered, which fits a laptop display.
This commit is contained in:
vincent
2026-08-29 02:44:39 +02:00
parent e75d896933
commit 11331671c5
5 changed files with 181 additions and 26 deletions
+19 -16
View File
@@ -80,29 +80,32 @@ fn bin(name: &str) -> String {
name.to_string()
}
fn version_of(name: &str) -> Option<String> {
std::process::Command::new(bin(name))
.arg("--version")
/// `flag` differs per tool: yt-dlp takes `--version`, ffmpeg only accepts
/// `-version` (it exits non-zero on `--version` and writes to stderr), so the
/// flag is passed in and both streams are consulted.
fn version_of(name: &str, flag: &str) -> Option<String> {
let out = std::process::Command::new(bin(name))
.arg(flag)
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| {
String::from_utf8_lossy(&o.stdout)
.lines()
.next()
.unwrap_or("")
.trim()
.to_string()
})
.filter(|s| !s.is_empty())
.ok()?;
if !out.status.success() {
return None;
}
let text = if out.stdout.is_empty() {
String::from_utf8_lossy(&out.stderr).to_string()
} else {
String::from_utf8_lossy(&out.stdout).to_string()
};
let first = text.lines().next().unwrap_or("").trim().to_string();
(!first.is_empty()).then_some(first)
}
#[tauri::command]
pub async fn check_prereqs(state: State<'_, AppState>) -> Result<Prereqs, String> {
let library = state.library.lock().await.clone();
Ok(Prereqs {
yt_dlp: version_of("yt-dlp"),
ffmpeg: version_of("ffmpeg").map(|v| {
yt_dlp: version_of("yt-dlp", "--version"),
ffmpeg: version_of("ffmpeg", "-version").map(|v| {
// ffmpeg's first line is long; keep the useful head of it.
v.split_whitespace().take(3).collect::<Vec<_>>().join(" ")
}),