1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Add option to not transcode original resolution

This commit is contained in:
Chocobozzz 2022-08-05 10:36:19 +02:00
parent 7e0f50d6e0
commit 84cae54e7a
No known key found for this signature in database
GPG key ID: 583A612D890159BE
26 changed files with 303 additions and 87 deletions

View file

@ -90,15 +90,21 @@ async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) {
// Resolutions
// ---------------------------------------------------------------------------
function computeLowerResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') {
function computeResolutionsToTranscode (options: {
inputResolution: number
type: 'vod' | 'live'
includeInputResolution: boolean
}) {
const { inputResolution, type, includeInputResolution } = options
const configResolutions = type === 'vod'
? CONFIG.TRANSCODING.RESOLUTIONS
: CONFIG.LIVE.TRANSCODING.RESOLUTIONS
const resolutionsEnabled: number[] = []
const resolutionsEnabled = new Set<number>()
// Put in the order we want to proceed jobs
const resolutions: VideoResolution[] = [
const availableResolutions: VideoResolution[] = [
VideoResolution.H_NOVIDEO,
VideoResolution.H_480P,
VideoResolution.H_360P,
@ -110,13 +116,17 @@ function computeLowerResolutionsToTranscode (videoFileResolution: number, type:
VideoResolution.H_4K
]
for (const resolution of resolutions) {
if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) {
resolutionsEnabled.push(resolution)
for (const resolution of availableResolutions) {
if (configResolutions[resolution + 'p'] === true && inputResolution > resolution) {
resolutionsEnabled.add(resolution)
}
}
return resolutionsEnabled
if (includeInputResolution) {
resolutionsEnabled.add(inputResolution)
}
return Array.from(resolutionsEnabled)
}
// ---------------------------------------------------------------------------
@ -224,7 +234,7 @@ export {
computeFPS,
getClosestFramerateStandard,
computeLowerResolutionsToTranscode,
computeResolutionsToTranscode,
canDoQuickTranscode,
canDoQuickVideoTranscode,