X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg%2Fffprobe-utils.ts;h=fb270b3cb5baf3617599edf8c7bb39005f5ece64;hb=6bcb854cdea8688a32240bc5719c7d139806e00b;hp=8ef42e792445d7f56ea5fb5a496b23a022fad36c;hpb=01ec3975e0775163740607b45e5a35ffc25b55ed;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg/ffprobe-utils.ts b/server/helpers/ffmpeg/ffprobe-utils.ts index 8ef42e792..fb270b3cb 100644 --- a/server/helpers/ffmpeg/ffprobe-utils.ts +++ b/server/helpers/ffmpeg/ffprobe-utils.ts @@ -15,6 +15,7 @@ import { import { VideoResolution, VideoTranscodingFPS } from '@shared/models' import { CONFIG } from '../../initializers/config' import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' +import { toEven } from '../core-utils' import { logger } from '../logger' /** @@ -55,14 +56,17 @@ async function getVideoStreamCodec (path: string) { baseProfile = baseProfileMatrix[videoCodec]['High'] // Fallback } - let level = videoStream.level.toString(16) - if (level.length === 1) level = `0${level}` - if (videoCodec === 'av01') { + let level = videoStream.level.toString() + if (level.length === 1) level = `0${level}` + // Guess the tier indicator and bit depth return `${videoCodec}.${baseProfile}.${level}M.08` } + let level = videoStream.level.toString(16) + if (level.length === 1) level = `0${level}` + // Default, h264 codec return `${videoCodec}.${baseProfile}${level}` } @@ -93,8 +97,9 @@ function computeResolutionsToTranscode (options: { type: 'vod' | 'live' includeInput: boolean strictLower: boolean + hasAudio: boolean }) { - const { input, type, includeInput, strictLower } = options + const { input, type, includeInput, strictLower, hasAudio } = options const configResolutions = type === 'vod' ? CONFIG.TRANSCODING.RESOLUTIONS @@ -122,12 +127,15 @@ function computeResolutionsToTranscode (options: { if (input < resolution) continue // We only want lower resolutions than input file if (strictLower && input === resolution) continue + // Audio resolutio but no audio in the video + if (resolution === VideoResolution.H_NOVIDEO && !hasAudio) continue resolutionsEnabled.add(resolution) } if (includeInput) { - resolutionsEnabled.add(input) + // Always use an even resolution to avoid issues with ffmpeg + resolutionsEnabled.add(toEven(input)) } return Array.from(resolutionsEnabled)