X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg-utils.ts;h=7bfd5d44acce0b5160a377c2fa0438fa85810bc9;hb=365d9083c938ea128e04c4f98e6b18dd26d86dd2;hp=557fb5e3aaf036c0547355aef3c8cc9d1a79876d;hpb=610d0be13b3d01f653ef269271dd667a57c85ef2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 557fb5e3a..7bfd5d44a 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -74,7 +74,7 @@ namespace audio { } } -function computeResolutionsToTranscode (videoFileHeight: number) { +function computeResolutionsToTranscode (videoFileResolution: number) { const resolutionsEnabled: number[] = [] const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS @@ -90,7 +90,7 @@ function computeResolutionsToTranscode (videoFileHeight: number) { ] for (const resolution of resolutions) { - if (configResolutions[resolution + 'p'] === true && videoFileHeight > resolution) { + if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) { resolutionsEnabled.push(resolution) } } @@ -338,11 +338,29 @@ function getClosestFramerateStandard (fps: number, type: 'HD_STANDARD' | 'STANDA .sort((a, b) => fps % a - fps % b)[0] } +function convertWebPToJPG (path: string, destination: string): Promise { + return new Promise(async (res, rej) => { + try { + const command = ffmpeg(path).output(destination) + + command.on('error', (err, stdout, stderr) => { + logger.error('Error in ffmpeg webp convert process.', { stdout, stderr }) + return rej(err) + }) + .on('end', () => res()) + .run() + } catch (err) { + return rej(err) + } + }) +} + // --------------------------------------------------------------------------- export { getVideoStreamCodec, getAudioStreamCodec, + convertWebPToJPG, getVideoStreamSize, getVideoFileResolution, getMetadataFromFile,