feat(transcode): add multi-resolution strategy with configurable ladders and fallback (#438)

* feat(transcode): add multi-resolution strategy with configurable ladders and fallback

* feat(settings): show toast on settings update and add manual verification plan to PR template

* fix(webui): preserve video resolution and fix 480p label in download dropdowns

* fix(webui): display standard short-side resolution for vertical videos in seekbar

* fix(webui): fix portrait transcode resolution labeling and serialize settings toggles
This commit is contained in:
Yiling-J
2026-10-01 13:27:50 +08:00
committed by GitHub
parent a84da8678e
commit e007054f47
35 changed files with 1260 additions and 123 deletions
+6 -2
View File
@@ -369,6 +369,7 @@ describe('TeamService', () => {
semanticSearchEnabled: false,
transcode: {
videoStrategy: 'best_match',
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
hardwareAcceleration: 'off',
threads: 0,
hlsEnabled: false,
@@ -385,6 +386,7 @@ describe('TeamService', () => {
semanticSearchEnabled: false,
transcode: {
videoStrategy: 'best_match',
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
hardwareAcceleration: 'off',
threads: 0,
hlsEnabled: false,
@@ -393,7 +395,8 @@ describe('TeamService', () => {
appearance: { hideAgent: false },
})
await teamService.updateSettings(team.id, 'transcode.videoStrategy', 'all')
await teamService.updateSettings(team.id, 'transcode.videoStrategy', 'multi')
await teamService.updateSettings(team.id, 'transcode.videoResolutions', ['720p', '1080p'])
await teamService.updateSettings(team.id, 'transcode.hardwareAcceleration', 'auto')
await teamService.updateSettings(team.id, 'transcode.threads', 4)
await teamService.updateSettings(team.id, 'transcode.hlsEnabled', true)
@@ -408,7 +411,8 @@ describe('TeamService', () => {
expect(finalSettings).toEqual({
theme: 'dark',
transcode: {
videoStrategy: 'all',
videoStrategy: 'multi',
videoResolutions: ['720p', '1080p'],
hardwareAcceleration: 'auto',
threads: 4,
hlsEnabled: true,
+27 -1
View File
@@ -35,6 +35,7 @@ export class TeamService {
settings: {
transcode: {
videoStrategy: 'best_match',
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
hardwareAcceleration: 'off',
threads: 0,
},
@@ -312,12 +313,22 @@ export class TeamService {
if (!settings.transcode) {
settings.transcode = {
videoStrategy: 'best_match',
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
hardwareAcceleration: 'off',
threads: 0,
hlsEnabled: false,
hlsResolutions: ['480p', '720p', '1080p'],
}
} else {
const strategyStr = settings.transcode.videoStrategy as string | undefined
if (strategyStr === 'single' || strategyStr === 'disable') {
settings.transcode.videoStrategy = 'best_match'
} else if (strategyStr === 'full' || strategyStr === 'all') {
settings.transcode.videoStrategy = 'multi'
}
if (!settings.transcode.videoResolutions) {
settings.transcode.videoResolutions = ['480p', '720p', '1080p', '1440p', '2160p']
}
if (settings.transcode.hlsEnabled === undefined) {
settings.transcode.hlsEnabled = false
}
@@ -345,10 +356,25 @@ export class TeamService {
if (!settings.transcode) {
settings.transcode = {}
}
settings.transcode.videoStrategy = value as NonNullable<
const rawStrategy = value as string
let strategy = rawStrategy
if (rawStrategy === 'single' || rawStrategy === 'disable') {
strategy = 'best_match'
} else if (rawStrategy === 'full' || rawStrategy === 'all') {
strategy = 'multi'
}
settings.transcode.videoStrategy = strategy as NonNullable<
TeamSettingsResponse['transcode']
>['videoStrategy']
delete settings['transcode.videoStrategy']
} else if (key === 'transcode.videoResolutions') {
if (!settings.transcode) {
settings.transcode = {}
}
settings.transcode.videoResolutions = value as NonNullable<
TeamSettingsResponse['transcode']
>['videoResolutions']
delete settings['transcode.videoResolutions']
} else if (key === 'transcode.hardwareAcceleration') {
if (!settings.transcode) {
settings.transcode = {}
+5 -3
View File
@@ -203,13 +203,14 @@ describe('UploadService', () => {
})
})
it('should pass custom transcode.threads from team settings to transcode task', async () => {
it('should pass custom transcode.threads and videoResolutions from team settings to transcode task', async () => {
await prisma.team.update({
where: { id: teamId },
data: {
settings: {
transcode: {
videoStrategy: 'all',
videoStrategy: 'multi',
videoResolutions: ['720p', '1080p'],
hardwareAcceleration: 'auto',
threads: 12,
},
@@ -245,7 +246,8 @@ describe('UploadService', () => {
expect(workflowTask?.payload).toEqual({
projectId: projectId,
transcode: {
videoStrategy: 'all',
videoStrategy: 'multi',
videoResolutions: ['720p', '1080p'],
hardwareAcceleration: 'auto',
threads: 12,
sprite: true,
+2
View File
@@ -334,12 +334,14 @@ export class UploadService {
const threads = settings?.transcode?.threads ?? 0
if (isVideo) {
const strategy = settings?.transcode?.videoStrategy || 'best_match'
const videoResolutions = settings?.transcode?.videoResolutions
const hardwareAcceleration = settings?.transcode?.hardwareAcceleration || 'off'
const hlsEnabled = settings?.transcode?.hlsEnabled ?? false
const hlsResolutions = settings?.transcode?.hlsResolutions
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await new VideoTranscoder(tx as any, asset.id, team.id, projectId)
.setStrategy(strategy)
.setVideoResolutions(videoResolutions)
.setHardwareAcceleration(hardwareAcceleration)
.setThreads(threads)
.setHls(hlsEnabled, hlsResolutions)