diff --git a/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_first_frame_to_jpg_thumbnail.rs b/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_first_frame_to_jpg_thumbnail.rs index 6f3b6b11b1..3df81bf0c9 100644 --- a/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_first_frame_to_jpg_thumbnail.rs +++ b/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_first_frame_to_jpg_thumbnail.rs @@ -6,9 +6,9 @@ use std::process::Command; use errors::AnyhowResult; -pub struct Args<'a> { - pub input_video_path: &'a Path, - pub output_jpg_path: &'a Path, +pub struct Args, O: AsRef> { + pub input_video_path: I, + pub output_jpg_path: O, } /// Extract a single JPG frame from a video file, scaled down to fit within @@ -16,17 +16,19 @@ pub struct Args<'a> { /// /// Uses `-sseof -1` to seek 1 second before the end of the file, which avoids /// potentially-black first frames. -pub fn ffmpeg_video_first_frame_to_jpg_thumbnail(args: Args<'_>) -> AnyhowResult<()> { +pub fn ffmpeg_video_first_frame_to_jpg_thumbnail, O: AsRef>( + args: Args, +) -> AnyhowResult<()> { let mut command = Command::new("ffmpeg"); command .arg("-nostdin") .arg("-y") .arg("-sseof").arg("-1") - .arg("-i").arg(args.input_video_path) + .arg("-i").arg(args.input_video_path.as_ref()) .arg("-vf").arg("scale=320:320:force_original_aspect_ratio=decrease") .arg("-vframes").arg("1") - .arg(args.output_jpg_path); + .arg(args.output_jpg_path.as_ref()); info!("Calling ffmpeg (jpg thumbnail)..."); diff --git a/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_gif_preview.rs b/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_gif_preview.rs index 878bb7f793..8cf5dfa184 100644 --- a/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_gif_preview.rs +++ b/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_video_gif_preview.rs @@ -6,16 +6,18 @@ use std::process::Command; use errors::AnyhowResult; -pub struct Args<'a> { - pub input_video_path: &'a Path, - pub output_gif_path: &'a Path, +pub struct Args, O: AsRef> { + pub input_video_path: I, + pub output_gif_path: O, } /// Extract a short animated GIF preview from a video file. /// /// Takes the first 5 seconds, resampled to 10 fps, scaled to 360px wide /// (preserving aspect ratio), with an optimized color palette. -pub fn ffmpeg_video_gif_preview(args: Args<'_>) -> AnyhowResult<()> { +pub fn ffmpeg_video_gif_preview, O: AsRef>( + args: Args, +) -> AnyhowResult<()> { let mut command = Command::new("ffmpeg"); command @@ -23,10 +25,10 @@ pub fn ffmpeg_video_gif_preview(args: Args<'_>) -> AnyhowResult<()> { .arg("-y") .arg("-ss").arg("0") .arg("-to").arg("5") - .arg("-i").arg(args.input_video_path) + .arg("-i").arg(args.input_video_path.as_ref()) .arg("-filter_complex") .arg("fps=10,scale=360:-1[s]; [s]split[a][b]; [a]palettegen[palette]; [b][palette]paletteuse") - .arg(args.output_gif_path); + .arg(args.output_gif_path.as_ref()); info!("Calling ffmpeg (gif preview)...");