2021-08-27 14:32:44 +02:00
|
|
|
import { Job } from 'bull'
|
2022-02-11 10:51:33 +01:00
|
|
|
import { TranscodeVODOptionsType } from '@server/helpers/ffmpeg'
|
2021-08-17 08:26:20 +02:00
|
|
|
import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
|
|
|
|
import { VideoPathManager } from '@server/lib/video-path-manager'
|
2021-11-09 11:52:41 +01:00
|
|
|
import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state'
|
2021-05-11 11:15:29 +02:00
|
|
|
import { UserModel } from '@server/models/user/user'
|
2021-08-17 08:26:20 +02:00
|
|
|
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
|
|
|
|
import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models'
|
2022-01-06 17:55:37 +01:00
|
|
|
import { pick } from '@shared/core-utils'
|
2020-04-23 09:32:53 +02:00
|
|
|
import {
|
2021-01-21 15:58:17 +01:00
|
|
|
HLSTranscodingPayload,
|
2020-04-23 09:32:53 +02:00
|
|
|
MergeAudioTranscodingPayload,
|
2022-02-01 11:16:45 +01:00
|
|
|
NewWebTorrentResolutionTranscodingPayload,
|
2020-04-23 09:32:53 +02:00
|
|
|
OptimizeTranscodingPayload,
|
2022-01-06 17:55:37 +01:00
|
|
|
VideoResolution,
|
2020-04-23 09:32:53 +02:00
|
|
|
VideoTranscodingPayload
|
2021-12-24 10:14:47 +01:00
|
|
|
} from '@shared/models'
|
2020-10-26 16:44:23 +01:00
|
|
|
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
2022-02-11 10:51:33 +01:00
|
|
|
import { computeLowerResolutionsToTranscode } from '../../../helpers/ffmpeg'
|
2021-08-26 09:18:57 +02:00
|
|
|
import { logger, loggerTagsFactory } from '../../../helpers/logger'
|
2020-10-26 16:44:23 +01:00
|
|
|
import { CONFIG } from '../../../initializers/config'
|
2017-12-12 17:53:50 +01:00
|
|
|
import { VideoModel } from '../../../models/video/video'
|
2021-01-21 15:58:17 +01:00
|
|
|
import {
|
|
|
|
generateHlsPlaylistResolution,
|
|
|
|
mergeAudioVideofile,
|
|
|
|
optimizeOriginalVideofile,
|
|
|
|
transcodeNewWebTorrentResolution
|
2022-02-11 10:51:33 +01:00
|
|
|
} from '../../transcoding/transcoding'
|
2022-08-02 16:05:44 +02:00
|
|
|
import { Hooks } from '@server/lib/plugins/hooks'
|
2021-01-21 15:58:17 +01:00
|
|
|
|
2021-08-27 14:32:44 +02:00
|
|
|
type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
|
2021-01-21 16:57:21 +01:00
|
|
|
|
2021-08-05 14:29:44 +02:00
|
|
|
const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = {
|
2021-01-21 15:58:17 +01:00
|
|
|
'new-resolution-to-hls': handleHLSJob,
|
|
|
|
'new-resolution-to-webtorrent': handleNewWebTorrentResolutionJob,
|
|
|
|
'merge-audio-to-webtorrent': handleWebTorrentMergeAudioJob,
|
|
|
|
'optimize-to-webtorrent': handleWebTorrentOptimizeJob
|
|
|
|
}
|
2017-10-02 12:20:26 +02:00
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
const lTags = loggerTagsFactory('transcoding')
|
|
|
|
|
2021-08-27 14:32:44 +02:00
|
|
|
async function processVideoTranscoding (job: Job) {
|
2019-03-19 17:00:08 +01:00
|
|
|
const payload = job.data as VideoTranscodingPayload
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
|
2018-01-25 15:05:18 +01:00
|
|
|
|
2022-06-28 14:57:51 +02:00
|
|
|
const video = await VideoModel.loadFull(payload.videoUUID)
|
2017-10-25 16:03:33 +02:00
|
|
|
// No video, maybe deleted?
|
|
|
|
if (!video) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
|
2017-10-25 16:03:33 +02:00
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
2021-01-21 16:57:21 +01:00
|
|
|
const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId)
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
const handler = handlers[payload.type]
|
2020-10-26 16:44:23 +01:00
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
if (!handler) {
|
2021-11-09 11:52:41 +01:00
|
|
|
await moveToFailedTranscodingState(video)
|
2021-12-03 14:40:29 +01:00
|
|
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
2021-11-09 11:52:41 +01:00
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
throw new Error('Cannot find transcoding handler for ' + payload.type)
|
|
|
|
}
|
2020-10-26 16:44:23 +01:00
|
|
|
|
2021-11-08 04:20:04 +01:00
|
|
|
try {
|
|
|
|
await handler(job, payload, video, user)
|
|
|
|
} catch (error) {
|
2021-11-09 11:52:41 +01:00
|
|
|
await moveToFailedTranscodingState(video)
|
2021-11-08 04:20:04 +01:00
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
|
|
|
|
2021-11-08 04:20:04 +01:00
|
|
|
throw error
|
|
|
|
}
|
2021-01-21 15:58:17 +01:00
|
|
|
|
|
|
|
return video
|
|
|
|
}
|
2019-01-29 08:37:25 +01:00
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
processVideoTranscoding
|
|
|
|
}
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Job handlers
|
|
|
|
// ---------------------------------------------------------------------------
|
2018-06-12 20:04:58 +02:00
|
|
|
|
2021-08-27 14:32:44 +02:00
|
|
|
async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
const videoFileInput = payload.copyCodecs
|
|
|
|
? video.getWebTorrentFile(payload.resolution)
|
|
|
|
: video.getMaxQualityFile()
|
|
|
|
|
|
|
|
const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist()
|
|
|
|
|
2021-11-18 14:35:08 +01:00
|
|
|
await VideoPathManager.Instance.makeAvailableVideoFile(videoFileInput.withVideoOrPlaylist(videoOrStreamingPlaylist), videoInputPath => {
|
2021-08-17 08:26:20 +02:00
|
|
|
return generateHlsPlaylistResolution({
|
|
|
|
video,
|
|
|
|
videoInputPath,
|
|
|
|
resolution: payload.resolution,
|
|
|
|
copyCodecs: payload.copyCodecs,
|
|
|
|
isPortraitMode: payload.isPortraitMode || false,
|
|
|
|
job
|
|
|
|
})
|
2021-01-21 15:58:17 +01:00
|
|
|
})
|
2019-05-16 16:55:34 +02:00
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-11-29 11:20:17 +01:00
|
|
|
await onHlsPlaylistGeneration(video, user, payload)
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
2018-06-12 20:04:58 +02:00
|
|
|
|
2021-01-21 16:57:21 +01:00
|
|
|
async function handleNewWebTorrentResolutionJob (
|
2021-08-27 14:32:44 +02:00
|
|
|
job: Job,
|
2022-02-01 11:16:45 +01:00
|
|
|
payload: NewWebTorrentResolutionTranscodingPayload,
|
2021-01-21 16:57:21 +01:00
|
|
|
video: MVideoFullLight,
|
|
|
|
user: MUserId
|
|
|
|
) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
await transcodeNewWebTorrentResolution(video, payload.resolution, payload.isPortraitMode || false, job)
|
2017-10-17 15:37:40 +02:00
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-11-29 11:20:17 +01:00
|
|
|
await onNewWebTorrentFileResolution(video, user, payload)
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
|
|
|
|
2021-08-27 14:32:44 +02:00
|
|
|
async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
await mergeAudioVideofile(video, payload.resolution, job)
|
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
await onVideoFirstWebTorrentTranscoding(video, payload, 'video', user)
|
2017-10-02 12:20:26 +02:00
|
|
|
}
|
|
|
|
|
2021-08-27 14:32:44 +02:00
|
|
|
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
|
2021-01-21 15:58:17 +01:00
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
await onVideoFirstWebTorrentTranscoding(video, payload, transcodeType, user)
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2021-02-08 10:51:10 +01:00
|
|
|
async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, payload: HLSTranscodingPayload) {
|
2021-11-18 14:35:08 +01:00
|
|
|
if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
|
2021-02-08 10:51:10 +01:00
|
|
|
// Remove webtorrent files if not enabled
|
2019-11-15 15:06:03 +01:00
|
|
|
for (const file of video.VideoFiles) {
|
2022-07-29 14:50:41 +02:00
|
|
|
await video.removeWebTorrentFile(file)
|
2019-11-15 15:06:03 +01:00
|
|
|
await file.destroy()
|
2018-06-28 16:58:15 +02:00
|
|
|
}
|
2018-06-12 20:04:58 +02:00
|
|
|
|
2019-11-15 15:06:03 +01:00
|
|
|
video.VideoFiles = []
|
2021-02-08 10:51:10 +01:00
|
|
|
|
|
|
|
// Create HLS new resolution jobs
|
2021-08-17 08:26:20 +02:00
|
|
|
await createLowerResolutionsJobs({
|
|
|
|
video,
|
|
|
|
user,
|
|
|
|
videoFileResolution: payload.resolution,
|
|
|
|
isPortraitMode: payload.isPortraitMode,
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio: payload.hasAudio,
|
2021-08-17 08:26:20 +02:00
|
|
|
isNewVideo: payload.isNewVideo ?? true,
|
|
|
|
type: 'hls'
|
|
|
|
})
|
2019-11-15 15:06:03 +01:00
|
|
|
}
|
2018-01-25 15:05:18 +01:00
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
2022-03-22 14:35:04 +01:00
|
|
|
await retryTransactionWrapper(moveToNextState, { video, isNewVideo: payload.isNewVideo })
|
2019-11-15 15:06:03 +01:00
|
|
|
}
|
2018-12-28 13:47:17 +01:00
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
async function onVideoFirstWebTorrentTranscoding (
|
2020-12-22 15:42:02 +01:00
|
|
|
videoArg: MVideoWithFile,
|
2021-02-08 10:51:10 +01:00
|
|
|
payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload,
|
2022-02-11 10:51:33 +01:00
|
|
|
transcodeType: TranscodeVODOptionsType,
|
2021-01-21 16:57:21 +01:00
|
|
|
user: MUserId
|
2020-12-22 15:42:02 +01:00
|
|
|
) {
|
2022-02-11 10:51:33 +01:00
|
|
|
const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
|
2018-06-12 20:04:58 +02:00
|
|
|
|
2021-06-15 09:17:19 +02:00
|
|
|
// Maybe the video changed in database, refresh it
|
2022-06-28 14:57:51 +02:00
|
|
|
const videoDatabase = await VideoModel.loadFull(videoArg.uuid)
|
2021-06-15 09:17:19 +02:00
|
|
|
// Video does not exist anymore
|
|
|
|
if (!videoDatabase) return undefined
|
|
|
|
|
|
|
|
// Generate HLS version of the original file
|
2021-08-17 08:26:20 +02:00
|
|
|
const originalFileHLSPayload = {
|
|
|
|
...payload,
|
|
|
|
|
2021-06-15 09:17:19 +02:00
|
|
|
isPortraitMode,
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio: !!audioStream,
|
2021-06-15 09:17:19 +02:00
|
|
|
resolution: videoDatabase.getMaxQualityFile().resolution,
|
|
|
|
// If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues
|
|
|
|
copyCodecs: transcodeType !== 'quick-transcode',
|
|
|
|
isMaxQuality: true
|
2021-08-17 08:26:20 +02:00
|
|
|
}
|
2021-06-15 09:17:19 +02:00
|
|
|
const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload)
|
2021-08-17 08:26:20 +02:00
|
|
|
const hasNewResolutions = await createLowerResolutionsJobs({
|
|
|
|
video: videoDatabase,
|
|
|
|
user,
|
|
|
|
videoFileResolution: resolution,
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio: !!audioStream,
|
2021-08-17 08:26:20 +02:00
|
|
|
isPortraitMode,
|
|
|
|
type: 'webtorrent',
|
|
|
|
isNewVideo: payload.isNewVideo ?? true
|
|
|
|
})
|
2018-03-19 15:02:36 +01:00
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
await VideoJobInfoModel.decrease(videoDatabase.uuid, 'pendingTranscode')
|
2018-12-28 13:47:17 +01:00
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
// Move to next state if there are no other resolutions to generate
|
2021-06-15 09:17:19 +02:00
|
|
|
if (!hasHls && !hasNewResolutions) {
|
2022-03-22 14:35:04 +01:00
|
|
|
await retryTransactionWrapper(moveToNextState, { video: videoDatabase, isNewVideo: payload.isNewVideo })
|
2021-06-15 09:17:19 +02:00
|
|
|
}
|
2017-10-02 12:20:26 +02:00
|
|
|
}
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
async function onNewWebTorrentFileResolution (
|
2021-08-17 08:26:20 +02:00
|
|
|
video: MVideo,
|
2021-01-21 16:57:21 +01:00
|
|
|
user: MUserId,
|
2022-02-01 11:16:45 +01:00
|
|
|
payload: NewWebTorrentResolutionTranscodingPayload | MergeAudioTranscodingPayload
|
2021-01-21 15:58:17 +01:00
|
|
|
) {
|
2022-02-01 11:16:45 +01:00
|
|
|
if (payload.createHLSIfNeeded) {
|
|
|
|
await createHlsJobIfEnabled(user, { hasAudio: true, copyCodecs: true, isMaxQuality: false, ...payload })
|
|
|
|
}
|
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
2021-01-21 15:58:17 +01:00
|
|
|
|
2022-03-22 14:35:04 +01:00
|
|
|
await retryTransactionWrapper(moveToNextState, { video, isNewVideo: payload.isNewVideo })
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
|
|
|
|
2021-12-03 14:40:29 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2021-01-21 16:57:21 +01:00
|
|
|
async function createHlsJobIfEnabled (user: MUserId, payload: {
|
|
|
|
videoUUID: string
|
|
|
|
resolution: number
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio: boolean
|
2021-01-21 16:57:21 +01:00
|
|
|
isPortraitMode?: boolean
|
|
|
|
copyCodecs: boolean
|
2021-02-08 10:51:10 +01:00
|
|
|
isMaxQuality: boolean
|
2021-08-17 08:26:20 +02:00
|
|
|
isNewVideo?: boolean
|
2021-01-21 16:57:21 +01:00
|
|
|
}) {
|
2021-08-17 08:26:20 +02:00
|
|
|
if (!payload || CONFIG.TRANSCODING.ENABLED !== true || CONFIG.TRANSCODING.HLS.ENABLED !== true) return false
|
2021-01-21 16:57:21 +01:00
|
|
|
|
|
|
|
const jobOptions = {
|
2021-05-05 09:25:11 +02:00
|
|
|
priority: await getTranscodingJobPriority(user)
|
2021-01-21 16:57:21 +01:00
|
|
|
}
|
2019-01-29 08:37:25 +01:00
|
|
|
|
2021-01-21 16:57:21 +01:00
|
|
|
const hlsTranscodingPayload: HLSTranscodingPayload = {
|
|
|
|
type: 'new-resolution-to-hls',
|
2021-11-18 14:35:08 +01:00
|
|
|
autoDeleteWebTorrentIfNeeded: true,
|
2022-01-06 17:55:37 +01:00
|
|
|
|
|
|
|
...pick(payload, [ 'videoUUID', 'resolution', 'isPortraitMode', 'copyCodecs', 'isMaxQuality', 'isNewVideo', 'hasAudio' ])
|
2019-01-29 08:37:25 +01:00
|
|
|
}
|
2021-01-21 16:57:21 +01:00
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
await addTranscodingJob(hlsTranscodingPayload, jobOptions)
|
2021-02-22 10:33:33 +01:00
|
|
|
|
|
|
|
return true
|
2019-01-29 08:37:25 +01:00
|
|
|
}
|
2021-01-21 15:58:17 +01:00
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
async function createLowerResolutionsJobs (options: {
|
|
|
|
video: MVideoFullLight
|
|
|
|
user: MUserId
|
|
|
|
videoFileResolution: number
|
|
|
|
isPortraitMode: boolean
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio: boolean
|
2021-08-17 08:26:20 +02:00
|
|
|
isNewVideo: boolean
|
2021-02-08 10:51:10 +01:00
|
|
|
type: 'hls' | 'webtorrent'
|
2021-08-17 08:26:20 +02:00
|
|
|
}) {
|
2022-01-06 17:55:37 +01:00
|
|
|
const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options
|
2021-08-17 08:26:20 +02:00
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
// Create transcoding jobs if there are enabled resolutions
|
2022-08-02 16:05:44 +02:00
|
|
|
const resolutionsEnabled = await Hooks.wrapObject(
|
|
|
|
computeLowerResolutionsToTranscode(videoFileResolution, 'vod'),
|
|
|
|
'filter:transcoding.auto.lower-resolutions-to-transcode.result',
|
|
|
|
options
|
|
|
|
)
|
|
|
|
|
2021-08-26 09:18:57 +02:00
|
|
|
const resolutionCreated: string[] = []
|
2021-01-21 15:58:17 +01:00
|
|
|
|
|
|
|
for (const resolution of resolutionsEnabled) {
|
2022-01-06 17:55:37 +01:00
|
|
|
if (resolution === VideoResolution.H_NOVIDEO && hasAudio === false) continue
|
|
|
|
|
2021-01-21 15:58:17 +01:00
|
|
|
let dataInput: VideoTranscodingPayload
|
|
|
|
|
2021-02-08 10:51:10 +01:00
|
|
|
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED && type === 'webtorrent') {
|
2021-01-21 15:58:17 +01:00
|
|
|
// WebTorrent will create subsequent HLS job
|
|
|
|
dataInput = {
|
|
|
|
type: 'new-resolution-to-webtorrent',
|
|
|
|
videoUUID: video.uuid,
|
|
|
|
resolution,
|
2021-08-17 08:26:20 +02:00
|
|
|
isPortraitMode,
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio,
|
2022-02-01 11:16:45 +01:00
|
|
|
createHLSIfNeeded: true,
|
2021-08-17 08:26:20 +02:00
|
|
|
isNewVideo
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
2021-08-26 09:18:57 +02:00
|
|
|
|
|
|
|
resolutionCreated.push('webtorrent-' + resolution)
|
2021-02-08 10:51:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (CONFIG.TRANSCODING.HLS.ENABLED && type === 'hls') {
|
2021-01-21 15:58:17 +01:00
|
|
|
dataInput = {
|
|
|
|
type: 'new-resolution-to-hls',
|
|
|
|
videoUUID: video.uuid,
|
|
|
|
resolution,
|
|
|
|
isPortraitMode,
|
2022-01-06 17:55:37 +01:00
|
|
|
hasAudio,
|
2021-02-08 10:51:10 +01:00
|
|
|
copyCodecs: false,
|
2021-08-17 08:26:20 +02:00
|
|
|
isMaxQuality: false,
|
2021-11-18 14:35:08 +01:00
|
|
|
autoDeleteWebTorrentIfNeeded: true,
|
2021-08-17 08:26:20 +02:00
|
|
|
isNewVideo
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
2021-08-26 09:18:57 +02:00
|
|
|
|
|
|
|
resolutionCreated.push('hls-' + resolution)
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 10:33:33 +01:00
|
|
|
if (!dataInput) continue
|
|
|
|
|
2021-01-21 16:57:21 +01:00
|
|
|
const jobOptions = {
|
2021-05-05 09:25:11 +02:00
|
|
|
priority: await getTranscodingJobPriority(user)
|
2021-01-21 16:57:21 +01:00
|
|
|
}
|
|
|
|
|
2021-08-17 08:26:20 +02:00
|
|
|
await addTranscodingJob(dataInput, jobOptions)
|
2021-01-21 15:58:17 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 10:33:33 +01:00
|
|
|
if (resolutionCreated.length === 0) {
|
2021-08-26 09:18:57 +02:00
|
|
|
logger.info('No transcoding jobs created for video %s (no resolutions).', video.uuid, lTags(video.uuid))
|
2021-02-22 10:33:33 +01:00
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.info(
|
|
|
|
'New resolutions %s transcoding jobs created for video %s and origin file resolution of %d.', type, video.uuid, videoFileResolution,
|
2021-08-26 09:18:57 +02:00
|
|
|
{ resolutionCreated, ...lTags(video.uuid) }
|
2021-02-22 10:33:33 +01:00
|
|
|
)
|
2021-01-21 15:58:17 +01:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|