fix: face thumbnail crop using bbox parameters
- Added bbox_x, bbox_y, bbox_w, bbox_h fields to ThumbQuery - face_thumbnail now uses bbox params for ffmpeg crop filter - Frontend passes bboxX/Y/Width/Height which maps to bbox_x/y/w/h
This commit is contained in:
@@ -775,6 +775,10 @@ struct ThumbQuery {
|
||||
y: Option<i32>,
|
||||
w: Option<i32>,
|
||||
h: Option<i32>,
|
||||
bbox_x: Option<i32>,
|
||||
bbox_y: Option<i32>,
|
||||
bbox_w: Option<i32>,
|
||||
bbox_h: Option<i32>,
|
||||
trace_id: Option<i32>,
|
||||
}
|
||||
|
||||
@@ -863,7 +867,12 @@ async fn face_thumbnail(
|
||||
}
|
||||
}
|
||||
|
||||
if let (Some(x), Some(y), Some(w), Some(h)) = (q.x, q.y, q.w, q.h) {
|
||||
let crop_x = q.x.or(q.bbox_x);
|
||||
let crop_y = q.y.or(q.bbox_y);
|
||||
let crop_w = q.w.or(q.bbox_w);
|
||||
let crop_h = q.h.or(q.bbox_h);
|
||||
|
||||
if let (Some(x), Some(y), Some(w), Some(h)) = (crop_x, crop_y, crop_w, crop_h) {
|
||||
if let (Some(vw), Some(vh)) = (video_width, video_height) {
|
||||
crate::core::thumbnail::validator::validate_crop(x, y, w, h, vw, vh).map_err(|e| {
|
||||
tracing::warn!("[thumbnail] Crop validation failed: {}", e);
|
||||
@@ -873,7 +882,7 @@ async fn face_thumbnail(
|
||||
}
|
||||
|
||||
let select = format!("select=eq(n\\,{})", frame);
|
||||
let vf = if let (Some(x), Some(y), Some(w), Some(h)) = (q.x, q.y, q.w, q.h) {
|
||||
let vf = if let (Some(x), Some(y), Some(w), Some(h)) = (crop_x, crop_y, crop_w, crop_h) {
|
||||
format!("{},crop={}:{}:{}:{}", select, w, h, x, y)
|
||||
} else {
|
||||
select
|
||||
@@ -1282,6 +1291,10 @@ async fn media_proxy_handler(
|
||||
y: params.get("y").and_then(|v| v.parse().ok()),
|
||||
w: params.get("w").and_then(|v| v.parse().ok()),
|
||||
h: params.get("h").and_then(|v| v.parse().ok()),
|
||||
bbox_x: params.get("bbox_x").and_then(|v| v.parse().ok()),
|
||||
bbox_y: params.get("bbox_y").and_then(|v| v.parse().ok()),
|
||||
bbox_w: params.get("bbox_w").and_then(|v| v.parse().ok()),
|
||||
bbox_h: params.get("bbox_h").and_then(|v| v.parse().ok()),
|
||||
trace_id: params.get("trace_id").and_then(|v| v.parse().ok()),
|
||||
};
|
||||
face_thumbnail(State(state), Path(uuid.clone()), Query(thumb_query))
|
||||
|
||||
Reference in New Issue
Block a user