mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-14 05:42:32 +00:00
ffprobe
This commit is contained in:
1 parent
06e04f7b29
commit
cf9f1bdd93
7 files changed
+68
-4
No files matched your search
Generated
+11
@@ -2507,6 +2507,16 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ffprobe"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ffef835e1f9ac151db5bb2adbb95c9dfe1f315f987f011dd89cd655b4e9a52c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filesys"
|
||||
version = "0.0.1"
|
||||
@@ -8040,6 +8050,7 @@ name = "videos"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"errors",
|
||||
"ffprobe",
|
||||
"log",
|
||||
"mp4",
|
||||
"my-workspace-hack",
|
||||
|
||||
@@ -25,8 +25,9 @@ errors = { path = "../../errors" }
|
||||
my-workspace-hack = { version = "0.1", path = "../../../my-workspace-hack" }
|
||||
|
||||
# External
|
||||
mp4 = "0.14.0"
|
||||
ffprobe = "0.4.0"
|
||||
log = "0.4.20"
|
||||
mp4 = "0.14.0"
|
||||
|
||||
[dev-dependencies]
|
||||
testing = { path = "../../testing" }
|
||||
@@ -0,0 +1,33 @@
|
||||
use std::path::Path;
|
||||
|
||||
use errors::AnyhowResult;
|
||||
|
||||
pub struct VideoDimensions {
|
||||
pub width: u64,
|
||||
pub height: u64,
|
||||
}
|
||||
|
||||
pub fn ffprobe_get_dimensions(
|
||||
video_path: impl AsRef<Path>
|
||||
) -> AnyhowResult<Option<VideoDimensions>>
|
||||
{
|
||||
let result = ffprobe::ffprobe(video_path)?;
|
||||
|
||||
let maybe_dimensions = result.streams.iter()
|
||||
.filter(|stream| stream.codec_type.as_deref() == Some("video"))
|
||||
.find_map(|stream| {
|
||||
if let (Some(width), Some(height)) = (stream.width, stream.height) {
|
||||
Some((width, height))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
match maybe_dimensions {
|
||||
None => Ok(None),
|
||||
Some((width, height)) => Ok(Some(VideoDimensions {
|
||||
width: width.unsigned_abs(),
|
||||
height: height.unsigned_abs(),
|
||||
})),
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,5 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
pub mod ffprobe_get_dimensions;
|
||||
pub mod get_mp4_info;
|
||||
+1
@@ -6,6 +6,7 @@ use buckets::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
use cloud_storage::remote_file_manager::remote_cloud_file_manager::RemoteCloudFileClient;
|
||||
use filesys::path_to_string::path_to_string;
|
||||
use mysql_queries::queries::media_files::get::get_media_file::{get_media_file, MediaFile};
|
||||
use videos::ffprobe_get_dimensions::ffprobe_get_dimensions;
|
||||
|
||||
use crate::job::job_loop::process_single_job_error::ProcessSingleJobError;
|
||||
use crate::job::job_types::workflow::comfy_ui::video_style_transfer::video_paths::VideoPaths;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
pub mod comfy_ui_inference_command;
|
||||
pub mod download_input_video;
|
||||
pub mod video_paths;
|
||||
pub mod process_job;
|
||||
pub mod validate_job;
|
||||
pub mod validate_and_save_results;
|
||||
mod write_workflow_prompt;
|
||||
pub mod validate_job;
|
||||
pub mod video_paths;
|
||||
pub mod write_workflow_prompt;
|
||||
+17
@@ -39,6 +39,7 @@ use subprocess_common::command_runner::command_runner_args::{RunAsSubprocessArgs
|
||||
use thumbnail_generator::task_client::thumbnail_task::ThumbnailTaskBuilder;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::prompts::PromptToken;
|
||||
use videos::ffprobe_get_dimensions::ffprobe_get_dimensions;
|
||||
|
||||
use crate::job::job_loop::job_success_result::{JobSuccessResult, ResultEntity};
|
||||
use crate::job::job_loop::process_single_job_error::ProcessSingleJobError;
|
||||
@@ -227,6 +228,10 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
|
||||
videos.debug_print_paths_after_download();
|
||||
|
||||
if let Ok(Some(dimensions)) = ffprobe_get_dimensions(&videos.original_video_path) {
|
||||
info!("Download video dimensions: {}x{}", dimensions.width, dimensions.height);
|
||||
}
|
||||
|
||||
// ========================= PROCESS VIDEO ======================== //
|
||||
|
||||
let target_fps = comfy_args.target_fps.unwrap_or(24);
|
||||
@@ -302,6 +307,10 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
|
||||
videos.debug_print_paths_after_trim();
|
||||
|
||||
if let Ok(Some(dimensions)) = ffprobe_get_dimensions(&videos.trimmed_resampled_video_path) {
|
||||
info!("Trimmed / resampled video dimensions: {}x{}", dimensions.width, dimensions.height);
|
||||
}
|
||||
|
||||
// make outputs dir if not exist
|
||||
let output_dir = root_comfy_path.join("output");
|
||||
if !output_dir.exists() {
|
||||
@@ -387,6 +396,10 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
|
||||
videos.debug_print_paths_after_comfy();
|
||||
|
||||
if let Ok(Some(dimensions)) = ffprobe_get_dimensions(&videos.comfy_output_video_path) {
|
||||
info!("Comfy output video dimensions: {}x{}", dimensions.width, dimensions.height);
|
||||
}
|
||||
|
||||
// ==================== CHECK OUTPUT FILE ======================== //
|
||||
|
||||
if let Err(err) = check_file_exists(&videos.comfy_output_video_path) {
|
||||
@@ -501,6 +514,10 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
|
||||
videos.debug_print_paths_after_post_processing();
|
||||
|
||||
if let Ok(Some(dimensions)) = ffprobe_get_dimensions(&videos.get_final_video_to_upload()) {
|
||||
info!("Final video upload dimensions: {}x{}", dimensions.width, dimensions.height);
|
||||
}
|
||||
|
||||
// ==================== VALIDATE AND SAVE RESULTS ======================== //
|
||||
|
||||
let media_file_token = validate_and_save_results(SaveResultsArgs {
|
||||
|
||||
Reference in new issue
Block a user