feat(transcode): add HLS live streaming support (#436)

* feat(transcode): add HLS live streaming support

* fix(hls): resolve version stacks for public HLS and add workflow E2E test
This commit is contained in:
Yiling-J
2026-09-30 16:31:40 +08:00
committed by GitHub
parent 5fe22ac52c
commit 123a8cb5f4
35 changed files with 2210 additions and 83 deletions
@@ -8,7 +8,11 @@ import {
failTask,
cleanupTmpDir,
} from './common'
import { getTargetVideoResolutions, resolutionToDimensions } from './transcode-utils'
import {
getTargetVideoResolutions,
getTargetHlsResolutions,
resolutionToDimensions,
} from './transcode-utils'
export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void> {
let tmpDir: string | undefined
@@ -21,6 +25,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
updateAssetStatusActivity,
getMediaInfoActivity,
transcodeVideoActivity,
transcodeHlsActivity,
transcodeAudioActivity,
transcodeImageActivity,
extractPosterActivity,
@@ -189,6 +194,35 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
mediaInfo.videoTranscodes.push(videoTranscode)
}
if (spec.hlsEnabled) {
const hlsLadders = getTargetHlsResolutions(
spec.hlsResolutions,
metadata.originalWidth,
metadata.originalHeight,
)
if (hlsLadders.length > 0) {
const hlsResult = await executeActivity(workerQueue, transcodeHlsActivity, {
taskId: task.id,
assetKey: key,
filePath,
ladders: hlsLadders,
originalWidth: metadata.originalWidth,
originalHeight: metadata.originalHeight,
originalFps: metadata.frameRate,
sourceVideoBitrate: metadata.videoBitRate || metadata.bitRate,
hardwareAcceleration: spec.hardwareAcceleration,
threads: spec.threads,
sourceIsHdr: metadata.isHdr,
sourceHdrType: metadata.hdrType,
sourceColorTransfer: metadata.colorTransfer,
sourceColorPrimaries: metadata.colorPrimaries,
sourceColorSpace: metadata.colorSpace,
})
mediaInfo.isHls = true
mediaInfo.hls = hlsResult
}
}
}
const isAudio = mediaInfo.proxyType === 'audio'