Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix encoder after transcoding profile deletion

Chocobozzz46950fbcc89a
diff --git a/packages/ffmpeg/src/ffmpeg-command-wrapper.ts b/packages/ffmpeg/src/ffmpeg-command-wrapper.ts
index 4a3b04bf11..50e842f76b 100644
--- a/packages/ffmpeg/src/ffmpeg-command-wrapper.ts
+++ b/packages/ffmpeg/src/ffmpeg-command-wrapper.ts
@@ -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
diff --git a/server/core/lib/transcoding/default-transcoding-profiles.ts b/server/core/lib/transcoding/default-transcoding-profiles.ts
index 639809be73..f1a2feaa2a 100644
--- a/server/core/lib/transcoding/default-transcoding-profiles.ts
+++ b/server/core/lib/transcoding/default-transcoding-profiles.ts
@@ -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 }
]
}
}