2023-04-21 15:05:27 +02:00
|
|
|
import { logger } from 'packages/peertube-runner/shared/logger'
|
|
|
|
import {
|
|
|
|
RunnerJobLiveRTMPHLSTranscodingPayload,
|
2023-05-04 15:29:34 +02:00
|
|
|
RunnerJobVideoEditionTranscodingPayload,
|
2023-04-21 15:05:27 +02:00
|
|
|
RunnerJobVODAudioMergeTranscodingPayload,
|
|
|
|
RunnerJobVODHLSTranscodingPayload,
|
|
|
|
RunnerJobVODWebVideoTranscodingPayload
|
|
|
|
} from '@shared/models'
|
|
|
|
import { processAudioMergeTranscoding, processHLSTranscoding, ProcessOptions, processWebVideoTranscoding } from './shared'
|
|
|
|
import { ProcessLiveRTMPHLSTranscoding } from './shared/process-live'
|
2023-05-04 15:29:34 +02:00
|
|
|
import { processStudioTranscoding } from './shared/process-studio'
|
2023-04-21 15:05:27 +02:00
|
|
|
|
|
|
|
export async function processJob (options: ProcessOptions) {
|
|
|
|
const { server, job } = options
|
|
|
|
|
|
|
|
logger.info(`[${server.url}] Processing job of type ${job.type}: ${job.uuid}`, { payload: job.payload })
|
|
|
|
|
|
|
|
if (job.type === 'vod-audio-merge-transcoding') {
|
|
|
|
await processAudioMergeTranscoding(options as ProcessOptions<RunnerJobVODAudioMergeTranscodingPayload>)
|
|
|
|
} else if (job.type === 'vod-web-video-transcoding') {
|
|
|
|
await processWebVideoTranscoding(options as ProcessOptions<RunnerJobVODWebVideoTranscodingPayload>)
|
|
|
|
} else if (job.type === 'vod-hls-transcoding') {
|
|
|
|
await processHLSTranscoding(options as ProcessOptions<RunnerJobVODHLSTranscodingPayload>)
|
|
|
|
} else if (job.type === 'live-rtmp-hls-transcoding') {
|
|
|
|
await new ProcessLiveRTMPHLSTranscoding(options as ProcessOptions<RunnerJobLiveRTMPHLSTranscodingPayload>).process()
|
2023-05-04 15:29:34 +02:00
|
|
|
} else if (job.type === 'video-edition-transcoding') {
|
|
|
|
await processStudioTranscoding(options as ProcessOptions<RunnerJobVideoEditionTranscodingPayload>)
|
2023-04-21 15:05:27 +02:00
|
|
|
} else {
|
|
|
|
logger.error(`Unknown job ${job.type} to process`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.info(`[${server.url}] Finished processing job of type ${job.type}: ${job.uuid}`)
|
|
|
|
}
|