From b5b61983a9e57a64697d88c42e508481c2190c75 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Tue, 17 Mar 2026 22:21:25 -0400 Subject: [PATCH] refactor --- Cargo.lock | 2 ++ .../src/ffmpeg}/ffmpeg_timestamp_from_duration.rs | 0 crates/lib/ffmpeg_utils/src/ffmpeg/mod.rs | 1 + crates/lib/ffmpeg_utils/src/ffprobe/mod.rs | 0 crates/lib/ffmpeg_utils/src/lib.rs | 3 +++ crates/lib/files/videos/Cargo.toml | 1 + crates/lib/files/videos/src/lib.rs | 1 - crates/service/job/inference_job/Cargo.toml | 1 + .../util/common_commands/ffmpeg/ffmpeg_resample_duration.rs | 2 +- .../common_commands/ffmpeg/ffmpeg_resample_fps_and_duration.rs | 2 +- crates/service/web/storyteller_web/Cargo.toml | 1 + .../upload/upload_video_new/ffmpeg_trim_and_resample.rs | 2 +- 12 files changed, 12 insertions(+), 4 deletions(-) rename crates/lib/{files/videos/src => ffmpeg_utils/src/ffmpeg}/ffmpeg_timestamp_from_duration.rs (100%) create mode 100644 crates/lib/ffmpeg_utils/src/ffmpeg/mod.rs create mode 100644 crates/lib/ffmpeg_utils/src/ffprobe/mod.rs diff --git a/Cargo.lock b/Cargo.lock index faf63a0994..333bfda1a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5955,6 +5955,7 @@ dependencies = [ "easyenv", "enums", "errors", + "ffmpeg_utils", "filesys", "google_drive_common", "hashing", @@ -11575,6 +11576,7 @@ dependencies = [ "enums_public", "errors", "fal_client", + "ffmpeg_utils", "filesys", "futures 0.1.31", "futures 0.3.31", diff --git a/crates/lib/files/videos/src/ffmpeg_timestamp_from_duration.rs b/crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_timestamp_from_duration.rs similarity index 100% rename from crates/lib/files/videos/src/ffmpeg_timestamp_from_duration.rs rename to crates/lib/ffmpeg_utils/src/ffmpeg/ffmpeg_timestamp_from_duration.rs diff --git a/crates/lib/ffmpeg_utils/src/ffmpeg/mod.rs b/crates/lib/ffmpeg_utils/src/ffmpeg/mod.rs new file mode 100644 index 0000000000..484dc3db94 --- /dev/null +++ b/crates/lib/ffmpeg_utils/src/ffmpeg/mod.rs @@ -0,0 +1 @@ +pub mod ffmpeg_timestamp_from_duration; diff --git a/crates/lib/ffmpeg_utils/src/ffprobe/mod.rs b/crates/lib/ffmpeg_utils/src/ffprobe/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/lib/ffmpeg_utils/src/lib.rs b/crates/lib/ffmpeg_utils/src/lib.rs index 6eb70013b9..db974f5ccb 100644 --- a/crates/lib/ffmpeg_utils/src/lib.rs +++ b/crates/lib/ffmpeg_utils/src/lib.rs @@ -17,3 +17,6 @@ // Always allow #![allow(dead_code)] #![allow(non_snake_case)] + +pub mod ffmpeg; +pub mod ffprobe; diff --git a/crates/lib/files/videos/Cargo.toml b/crates/lib/files/videos/Cargo.toml index 4e70c27166..8e2b6b9184 100644 --- a/crates/lib/files/videos/Cargo.toml +++ b/crates/lib/files/videos/Cargo.toml @@ -26,6 +26,7 @@ errors.workspace = true # External ffprobe = "0.4.0" log.workspace = true + # TODO(bt,2024-08-08): We might drop `mp4` crate because it crashes on reading # some videos with the message "avcc not found" mp4 = "0.14.0" diff --git a/crates/lib/files/videos/src/lib.rs b/crates/lib/files/videos/src/lib.rs index a8961779a2..387e1e0bc4 100644 --- a/crates/lib/files/videos/src/lib.rs +++ b/crates/lib/files/videos/src/lib.rs @@ -18,7 +18,6 @@ #![allow(dead_code)] #![allow(non_snake_case)] -pub mod ffmpeg_timestamp_from_duration; pub mod ffprobe_get_dimensions; pub mod ffprobe_get_info; pub mod get_mp4_info; diff --git a/crates/service/job/inference_job/Cargo.toml b/crates/service/job/inference_job/Cargo.toml index 882cc6ed83..9826deedc9 100644 --- a/crates/service/job/inference_job/Cargo.toml +++ b/crates/service/job/inference_job/Cargo.toml @@ -49,6 +49,7 @@ subprocess_common = { path = "../../../lib/subprocess_common" } thumbnail_generator = { path = "../../../api_clients/thumbnail_generator"} tokens.workspace = true tts_common = { path = "../../../lib/tts_common" } +ffmpeg_utils.workspace = true videos = { path = "../../../lib/files/videos" } # External diff --git a/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_duration.rs b/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_duration.rs index c65e6a4a30..6db3ae0e1a 100644 --- a/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_duration.rs +++ b/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_duration.rs @@ -3,7 +3,7 @@ use log::debug; use std::path::Path; use std::time::Duration; use subprocess_common::command_runner::command_args::CommandArgs; -use videos::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; +use ffmpeg_utils::ffmpeg::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; /// Trim a video's duration /// See: https://shotstack.io/learn/use-ffmpeg-to-trim-video/ diff --git a/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_fps_and_duration.rs b/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_fps_and_duration.rs index dd0721bd0d..d994271e5b 100644 --- a/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_fps_and_duration.rs +++ b/crates/service/job/inference_job/src/util/common_commands/ffmpeg/ffmpeg_resample_fps_and_duration.rs @@ -3,7 +3,7 @@ use log::debug; use std::path::Path; use std::time::Duration; use subprocess_common::command_runner::command_args::CommandArgs; -use videos::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; +use ffmpeg_utils::ffmpeg::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; /// Resample a video's frame rate /// See: https://trac.ffmpeg.org/wiki/ChangingFrameRate diff --git a/crates/service/web/storyteller_web/Cargo.toml b/crates/service/web/storyteller_web/Cargo.toml index 60833e2d15..8ca2da612e 100644 --- a/crates/service/web/storyteller_web/Cargo.toml +++ b/crates/service/web/storyteller_web/Cargo.toml @@ -82,6 +82,7 @@ url_config = { path = "../../../lib/url_config" } url_utils = { path = "../../../lib/url_utils" } user_input_common = { path = "../../../lib/user_input_common" } users.workspace = true +ffmpeg_utils.workspace = true videos = { path = "../../../lib/files/videos" } world_labs_api.workspace = true diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/media_files/upload/upload_video_new/ffmpeg_trim_and_resample.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/media_files/upload/upload_video_new/ffmpeg_trim_and_resample.rs index 061ebcc89b..311b521d9e 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/media_files/upload/upload_video_new/ffmpeg_trim_and_resample.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/media_files/upload/upload_video_new/ffmpeg_trim_and_resample.rs @@ -6,7 +6,7 @@ use std::process::Command; use std::time::Duration; use errors::AnyhowResult; -use videos::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; +use ffmpeg_utils::ffmpeg::ffmpeg_timestamp_from_duration::ffmpeg_timestamp_from_duration; pub struct Args<'a> { pub video_input_path: &'a Path,