From d178c28540d61669a535559fea9165c27a136dee Mon Sep 17 00:00:00 2001 From: fatchan Date: Sun, 26 May 2019 12:37:35 +0000 Subject: [PATCH] allow .mov and fix video resolution -- filter streams to only video --- helpers/files/file-check-mime-types.js | 1 + models/forms/make-post.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helpers/files/file-check-mime-types.js b/helpers/files/file-check-mime-types.js index 2f1eedad..55aef447 100644 --- a/helpers/files/file-check-mime-types.js +++ b/helpers/files/file-check-mime-types.js @@ -13,6 +13,7 @@ const animatedImageMimeTypes = new Set([ ]); const videoMimeTypes = new Set([ + 'video/quicktime', 'video/mp4', 'video/webm', ]); diff --git a/models/forms/make-post.js b/models/forms/make-post.js index ca8e9d03..3619e6be 100644 --- a/models/forms/make-post.js +++ b/models/forms/make-post.js @@ -122,6 +122,7 @@ module.exports = async (req, res, next, numFiles) => { //video metadata await videoUpload(file, filename, 'img'); const videoData = await videoIdentify(filename); + videoData.streams = videoData.streams.filter(stream => stream.width != null); //filter to only video streams or something with a resolution processedFile.duration = videoData.format.duration; processedFile.durationString = new Date(videoData.format.duration*1000).toLocaleString('en-US', {hour12:false}).split(' ')[1].replace(/^00:/, ''); processedFile.geometry = {width: videoData.streams[0].coded_width, height: videoData.streams[0].coded_height} // object with width and height pixels @@ -131,7 +132,7 @@ module.exports = async (req, res, next, numFiles) => { await videoThumbnail(filename); break; default: - return next(err); + return next(new Error(`invalid file mime type: ${mainType}`)); } //delete the temp file