Fix encoder after transcoding profile deletion

pull/6272/head
Chocobozzz 2024-03-12 10:44:20 +01:00
parent fb50a233f4
commit 46950fbcc8
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
import { pick, promisify0 } from '@peertube/peertube-core-utils'
import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptionsBuilderParams, EncoderProfile } from '@peertube/peertube-models'
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
type FFmpegLogger = {
info: (msg: string, obj?: any) => void

View File

@ -70,18 +70,26 @@ class VideoTranscodingProfilesManager {
const { type, encoder, profile } = options
delete this.availableEncoders[type][encoder][profile]
this.buildAvailableProfiles()
}
addEncoderPriority (type: 'vod' | 'live', streamType: 'audio' | 'video', encoder: string, priority: number) {
this.encodersPriorities[type][streamType].push({ name: encoder, priority })
this.encodersPriorities[type][streamType].push({ name: encoder, priority, isDefault: false })
FFmpegCommandWrapper.resetSupportedEncoders()
}
removeEncoderPriority (type: 'vod' | 'live', streamType: 'audio' | 'video', encoder: string, priority: number) {
this.encodersPriorities[type][streamType] = this.encodersPriorities[type][streamType]
.filter(o => o.name !== encoder && o.priority !== priority)
.filter(o => {
// Don't remove default encoders
if (o.isDefault) return true
// Don't include this encoder anymore
if (o.name === encoder && o.priority === priority) return false
return true
})
FFmpegCommandWrapper.resetSupportedEncoders()
}
@ -118,14 +126,14 @@ class VideoTranscodingProfilesManager {
private buildDefaultEncodersPriorities () {
return {
video: [
{ name: 'libx264', priority: 100 }
{ name: 'libx264', priority: 100, isDefault: true }
],
// Try the first one, if not available try the second one etc
audio: [
// we favor VBR, if a good AAC encoder is available
{ name: 'libfdk_aac', priority: 200 },
{ name: 'aac', priority: 100 }
{ name: 'libfdk_aac', priority: 200, isDefault: true },
{ name: 'aac', priority: 100, isDefault: true }
]
}
}