2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 19:31:35 +00:00

Support mp4

This commit is contained in:
asonix 2020-07-11 16:01:09 -05:00
parent d28d56fb9a
commit de3e04a411

View file

@ -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) {