X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg-utils.ts;h=132f4690ec715063fa1abcdd56e0450a553cbe2c;hb=4348a27d252a3349bafa7ef4859c0e2cf060c255;hp=b59e7e40e692e99ef19bb5e49b6d4745ae412a35;hpb=bc22d60899e14631cba0fb6450f4e85fc9528293;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index b59e7e40e..132f4690e 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -41,7 +41,7 @@ async function getVideoFileResolution (path: string) { async function getVideoFileFPS (path: string) { const videoStream = await getVideoFileStream(path) - for (const key of [ 'r_frame_rate' , 'avg_frame_rate' ]) { + for (const key of [ 'avg_frame_rate', 'r_frame_rate' ]) { const valuesText: string = videoStream[key] if (!valuesText) continue @@ -184,7 +184,7 @@ function getVideoFileStream (path: string) { if (err) return rej(err) const videoStream = metadata.streams.find(s => s.codec_type === 'video') - if (!videoStream) throw new Error('Cannot find video stream of ' + path) + if (!videoStream) return rej(new Error('Cannot find video stream of ' + path)) return res(videoStream) }) @@ -328,10 +328,10 @@ async function presetH264 (command: ffmpeg.FfmpegCommand, resolution: VideoResol const audioCodecName = parsedAudio.audioStream[ 'codec_name' ] let bitrate: number if (audio.bitrate[ audioCodecName ]) { - bitrate = audio.bitrate[ audioCodecName ](parsedAudio.audioStream[ 'bit_rate' ]) + localCommand = localCommand.audioCodec('aac') - if (bitrate === -1) localCommand = localCommand.audioCodec('copy') - else if (bitrate !== undefined) localCommand = localCommand.audioBitrate(bitrate) + bitrate = audio.bitrate[ audioCodecName ](parsedAudio.audioStream[ 'bit_rate' ]) + if (bitrate !== undefined && bitrate !== -1) localCommand = localCommand.audioBitrate(bitrate) } }