1
0
Fork 0

Fix encoder after transcoding profile deletion

This commit is contained in:
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 { pick, promisify0 } from '@peertube/peertube-core-utils'
import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptionsBuilderParams, EncoderProfile } from '@peertube/peertube-models' import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptionsBuilderParams, EncoderProfile } from '@peertube/peertube-models'
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
type FFmpegLogger = { type FFmpegLogger = {
info: (msg: string, obj?: any) => void info: (msg: string, obj?: any) => void

View file

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