aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/activitypub/misc.ts3
-rw-r--r--server/helpers/ffmpeg-utils.ts22
2 files changed, 8 insertions, 17 deletions
diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts
index f9445929b..5afcfbedc 100644
--- a/server/helpers/custom-validators/activitypub/misc.ts
+++ b/server/helpers/custom-validators/activitypub/misc.ts
@@ -25,8 +25,7 @@ function isActivityPubUrlValid (url: string) {
25} 25}
26 26
27function isBaseActivityValid (activity: any, type: string) { 27function isBaseActivityValid (activity: any, type: string) {
28 return (activity['@context'] === undefined || Array.isArray(activity['@context'])) && 28 return activity.type === type &&
29 activity.type === type &&
30 isActivityPubUrlValid(activity.id) && 29 isActivityPubUrlValid(activity.id) &&
31 isObjectValid(activity.actor) && 30 isObjectValid(activity.actor) &&
32 isUrlCollectionValid(activity.to) && 31 isUrlCollectionValid(activity.to) &&
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index af92d1ba9..2fdf34cb7 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -139,6 +139,7 @@ function transcode (options: TranscodeOptions) {
139 if (options.hlsPlaylist) { 139 if (options.hlsPlaylist) {
140 throw(Error("Quick transcode and HLS can't be used at the same time")) 140 throw(Error("Quick transcode and HLS can't be used at the same time"))
141 } 141 }
142
142 command 143 command
143 .format('mp4') 144 .format('mp4')
144 .addOption('-c:v copy') 145 .addOption('-c:v copy')
@@ -182,25 +183,16 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
182 const resolution = await getVideoFileResolution(path) 183 const resolution = await getVideoFileResolution(path)
183 184
184 // check video params 185 // check video params
185 if (videoStream[ 'codec_name' ] !== 'h264') { 186 if (videoStream[ 'codec_name' ] !== 'h264') return false
186 return false 187 if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false
187 } 188 if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false
188 if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) {
189 return false
190 }
191 if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) {
192 return false
193 }
194 189
195 // check audio params (if audio stream exists) 190 // check audio params (if audio stream exists)
196 if (parsedAudio.audioStream) { 191 if (parsedAudio.audioStream) {
197 if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') { 192 if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') return false
198 return false 193
199 }
200 const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ]) 194 const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ])
201 if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) { 195 if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) return false
202 return false
203 }
204 } 196 }
205 197
206 return true 198 return true