From de3e04a411a7a74dba297577223328c1510fc731 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 11 Jul 2020 16:01:09 -0500 Subject: [PATCH] Support mp4 --- src/validate/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/validate/mod.rs b/src/validate/mod.rs index af7bd9e..c59ecb6 100644 --- a/src/validate/mod.rs +++ b/src/validate/mod.rs @@ -105,7 +105,7 @@ pub(crate) async fn validate_image( let content_type = match (prescribed_format, meta.get_media_type()?) { (_, MediaType::Gif) => { let newfile = tmp_file(); - validate_gif(&tmpfile, &newfile)?; + validate_frames(&tmpfile, &newfile)?; video_mp4() } @@ -173,6 +173,12 @@ pub(crate) async fn validate_image( format.to_mime() } + (_, MediaType::Other(mp4)) if mp4 == "video/mp4" || mp4 == "video/quicktime" => { + let newfile = tmp_file(); + validate_frames(&tmpfile, &newfile)?; + + video_mp4() + } (_, media_type) => { warn!("Unsupported media type, {}", media_type); return Err(UploadError::UnsupportedFormat); @@ -188,7 +194,7 @@ pub(crate) async fn validate_image( } #[instrument] -fn validate_gif(from: &PathBuf, to: &PathBuf) -> Result<(), GifError> { +fn validate_frames(from: &PathBuf, to: &PathBuf) -> Result<(), GifError> { debug!("Transmuting GIF"); if let Err(e) = self::transcode::transcode(from, to, Target::Mp4) {