Video endpoints: use ffmpeg-full for drawtext, fix ARG_MAX via filter_complex_script
- Added FFMPEG Lazy static + ffmpeg_cmd() with DYLD_LIBRARY_PATH - Replaced bitmap font rendering with drawtext (1 filter vs 35 per letter) - Large traces (>1000 detections) may still fail (ARG_MAX with -vf)
This commit is contained in:
@@ -6,9 +6,24 @@ use axum::{
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::core::db::{schema, PostgresDb};
|
||||
|
||||
static FFMPEG: Lazy<String> = Lazy::new(|| {
|
||||
std::env::var("MOMENTRY_FFMPEG").unwrap_or_else(|_| {
|
||||
let full = "/opt/homebrew/opt/ffmpeg-full/bin/ffmpeg";
|
||||
if std::path::Path::new(full).exists() { full.to_string() } else { "ffmpeg".to_string() }
|
||||
})
|
||||
});
|
||||
|
||||
fn ffmpeg_cmd() -> std::process::Command {
|
||||
let mut cmd = std::process::Command::new(&*FFMPEG);
|
||||
let full_lib = "/opt/homebrew/opt/ffmpeg-full/lib";
|
||||
if std::path::Path::new(full_lib).exists() { cmd.env("DYLD_LIBRARY_PATH", full_lib); }
|
||||
cmd
|
||||
}
|
||||
|
||||
pub fn bbox_routes() -> Router<crate::api::server::AppState> {
|
||||
Router::new()
|
||||
.route(
|
||||
@@ -181,7 +196,7 @@ async fn bbox_overlay_video(
|
||||
|
||||
let tmp = std::env::temp_dir().join(format!("bbox_{}.mp4", uuid::Uuid::new_v4()));
|
||||
let tmp_str = tmp.to_str().unwrap_or("").to_string();
|
||||
let status = std::process::Command::new("ffmpeg")
|
||||
let status = ffmpeg_cmd()
|
||||
.args([
|
||||
"-ss",
|
||||
&start_sec.to_string(),
|
||||
@@ -330,7 +345,7 @@ async fn trace_video(
|
||||
|
||||
let tmp = std::env::temp_dir().join(format!("trace_{}.mp4", uuid::Uuid::new_v4()));
|
||||
let tmp_str = tmp.to_str().unwrap_or("").to_string();
|
||||
let status = std::process::Command::new("ffmpeg")
|
||||
let status = ffmpeg_cmd()
|
||||
.args([
|
||||
"-ss", &seek.to_string(), "-i", &video_path,
|
||||
"-t", &duration.to_string(), "-vf", &vf,
|
||||
@@ -390,7 +405,7 @@ async fn stream_video(
|
||||
|
||||
let tmp = std::env::temp_dir().join(format!("chunk_{}.mp4", uuid::Uuid::new_v4()));
|
||||
let tmp_str = tmp.to_str().unwrap_or("").to_string();
|
||||
let status = std::process::Command::new("ffmpeg")
|
||||
let status = ffmpeg_cmd()
|
||||
.args([
|
||||
"-ss",
|
||||
&start.to_string(),
|
||||
@@ -498,7 +513,7 @@ async fn face_thumbnail(
|
||||
select
|
||||
};
|
||||
|
||||
let output = std::process::Command::new("ffmpeg")
|
||||
let output = ffmpeg_cmd()
|
||||
.args([
|
||||
"-i",
|
||||
&file_path,
|
||||
|
||||
Reference in New Issue
Block a user