mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 00:47:53 +00:00
emit ffprobe on video upload
This commit is contained in:
1 parent
6d4adfe60f
commit
bda8cb5e10
2 files changed
+24
-1
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use std::path::Path;
|
||||
|
||||
use log::info;
|
||||
use errors::AnyhowResult;
|
||||
|
||||
pub struct VideoDimensions {
|
||||
@@ -23,6 +23,16 @@ pub fn ffprobe_get_dimensions(
|
||||
}
|
||||
});
|
||||
|
||||
let video_streams = result.streams.iter()
|
||||
.filter(|stream| stream.codec_type.as_deref() == Some("video"));
|
||||
|
||||
for stream in video_streams {
|
||||
info!("r_frame_rate: {}", stream.r_frame_rate);
|
||||
info!("avg_frame_rate: {}", stream.avg_frame_rate);
|
||||
info!("duration_ts: {:?}", stream.duration_ts);
|
||||
info!("durations: {:?}", stream.duration);
|
||||
}
|
||||
|
||||
match maybe_dimensions {
|
||||
None => Ok(None),
|
||||
Some((width, height)) => Ok(Some(VideoDimensions {
|
||||
|
||||
+13
@@ -30,6 +30,7 @@ use mysql_queries::queries::media_files::create::insert_media_file_from_file_upl
|
||||
use mysql_queries::queries::media_files::get::get_media_file::get_media_file;
|
||||
use thumbnail_generator::task_client::thumbnail_task::{ThumbnailTaskBuilder, ThumbnailTaskInputMimeType};
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use videos::ffprobe_get_dimensions::ffprobe_get_dimensions;
|
||||
use videos::get_mp4_info::{get_mp4_info, get_mp4_info_for_bytes, get_mp4_info_for_bytes_and_len};
|
||||
|
||||
use crate::http_server::endpoints::media_files::upload::upload_error::MediaFileUploadError;
|
||||
@@ -228,6 +229,18 @@ pub async fn upload_new_video_media_file_handler(
|
||||
|
||||
// ==================== DURATION DETECTION ==================== //
|
||||
|
||||
match ffprobe_get_dimensions(form.file.file.path()) {
|
||||
Err(err) => {
|
||||
warn!("Error reading video dimensions with ffprobe: {:?}", err);
|
||||
}
|
||||
Ok(Some(dims)) => {
|
||||
info!("Video dimensions: {}x{}", dims.width, dims.height);
|
||||
}
|
||||
Ok(None) => {
|
||||
warn!("No video dimensions found");
|
||||
}
|
||||
}
|
||||
|
||||
let mp4_info = get_mp4_info_for_bytes(file_bytes.as_ref())
|
||||
.map_err(|err| {
|
||||
warn!("Error reading mp4 info: {:?}", err);
|
||||
|
||||
Reference in new issue
Block a user