Better logs for transcoding
This commit is contained in:
parent
18305950c3
commit
5a298a5a3d
|
@ -15,7 +15,7 @@ import {
|
||||||
} from '../../../../shared'
|
} from '../../../../shared'
|
||||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||||
import { computeResolutionsToTranscode } from '../../../helpers/ffprobe-utils'
|
import { computeResolutionsToTranscode } from '../../../helpers/ffprobe-utils'
|
||||||
import { logger } from '../../../helpers/logger'
|
import { logger, loggerTagsFactory } from '../../../helpers/logger'
|
||||||
import { CONFIG } from '../../../initializers/config'
|
import { CONFIG } from '../../../initializers/config'
|
||||||
import { VideoModel } from '../../../models/video/video'
|
import { VideoModel } from '../../../models/video/video'
|
||||||
import {
|
import {
|
||||||
|
@ -34,14 +34,16 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } =
|
||||||
'optimize-to-webtorrent': handleWebTorrentOptimizeJob
|
'optimize-to-webtorrent': handleWebTorrentOptimizeJob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lTags = loggerTagsFactory('transcoding')
|
||||||
|
|
||||||
async function processVideoTranscoding (job: Bull.Job) {
|
async function processVideoTranscoding (job: Bull.Job) {
|
||||||
const payload = job.data as VideoTranscodingPayload
|
const payload = job.data as VideoTranscodingPayload
|
||||||
logger.info('Processing video file in job %d.', job.id)
|
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
|
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
|
||||||
// No video, maybe deleted?
|
// No video, maybe deleted?
|
||||||
if (!video) {
|
if (!video) {
|
||||||
logger.info('Do not process job %d, video does not exist.', job.id)
|
logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +65,8 @@ async function processVideoTranscoding (job: Bull.Job) {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
|
async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
|
||||||
|
logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
const videoFileInput = payload.copyCodecs
|
const videoFileInput = payload.copyCodecs
|
||||||
? video.getWebTorrentFile(payload.resolution)
|
? video.getWebTorrentFile(payload.resolution)
|
||||||
: video.getMaxQualityFile()
|
: video.getMaxQualityFile()
|
||||||
|
@ -80,6 +84,8 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await retryTransactionWrapper(onHlsPlaylistGeneration, video, user, payload)
|
await retryTransactionWrapper(onHlsPlaylistGeneration, video, user, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,28 +95,38 @@ async function handleNewWebTorrentResolutionJob (
|
||||||
video: MVideoFullLight,
|
video: MVideoFullLight,
|
||||||
user: MUserId
|
user: MUserId
|
||||||
) {
|
) {
|
||||||
|
logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await transcodeNewWebTorrentResolution(video, payload.resolution, payload.isPortraitMode || false, job)
|
await transcodeNewWebTorrentResolution(video, payload.resolution, payload.isPortraitMode || false, job)
|
||||||
|
|
||||||
|
logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
|
await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
|
logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await mergeAudioVideofile(video, payload.resolution, job)
|
await mergeAudioVideofile(video, payload.resolution, job)
|
||||||
|
|
||||||
|
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user)
|
await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
|
logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
|
const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
|
||||||
|
|
||||||
|
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await retryTransactionWrapper(onVideoFileOptimizer, video, payload, transcodeType, user)
|
await retryTransactionWrapper(onVideoFileOptimizer, video, payload, transcodeType, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, payload: HLSTranscodingPayload) {
|
async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, payload: HLSTranscodingPayload) {
|
||||||
if (video === undefined) return undefined
|
|
||||||
|
|
||||||
if (payload.isMaxQuality && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
|
if (payload.isMaxQuality && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
|
||||||
// Remove webtorrent files if not enabled
|
// Remove webtorrent files if not enabled
|
||||||
for (const file of video.VideoFiles) {
|
for (const file of video.VideoFiles) {
|
||||||
|
@ -141,9 +157,6 @@ async function onVideoFileOptimizer (
|
||||||
transcodeType: TranscodeOptionsType,
|
transcodeType: TranscodeOptionsType,
|
||||||
user: MUserId
|
user: MUserId
|
||||||
) {
|
) {
|
||||||
if (videoArg === undefined) return undefined
|
|
||||||
|
|
||||||
// Outside the transaction (IO on disk)
|
|
||||||
const { resolution, isPortraitMode } = await videoArg.getMaxQualityResolution()
|
const { resolution, isPortraitMode } = await videoArg.getMaxQualityResolution()
|
||||||
|
|
||||||
// Maybe the video changed in database, refresh it
|
// Maybe the video changed in database, refresh it
|
||||||
|
@ -241,7 +254,7 @@ async function createLowerResolutionsJobs (options: {
|
||||||
|
|
||||||
// Create transcoding jobs if there are enabled resolutions
|
// Create transcoding jobs if there are enabled resolutions
|
||||||
const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution, 'vod')
|
const resolutionsEnabled = computeResolutionsToTranscode(videoFileResolution, 'vod')
|
||||||
const resolutionCreated: number[] = []
|
const resolutionCreated: string[] = []
|
||||||
|
|
||||||
for (const resolution of resolutionsEnabled) {
|
for (const resolution of resolutionsEnabled) {
|
||||||
let dataInput: VideoTranscodingPayload
|
let dataInput: VideoTranscodingPayload
|
||||||
|
@ -255,6 +268,8 @@ async function createLowerResolutionsJobs (options: {
|
||||||
isPortraitMode,
|
isPortraitMode,
|
||||||
isNewVideo
|
isNewVideo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolutionCreated.push('webtorrent-' + resolution)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG.TRANSCODING.HLS.ENABLED && type === 'hls') {
|
if (CONFIG.TRANSCODING.HLS.ENABLED && type === 'hls') {
|
||||||
|
@ -267,12 +282,12 @@ async function createLowerResolutionsJobs (options: {
|
||||||
isMaxQuality: false,
|
isMaxQuality: false,
|
||||||
isNewVideo
|
isNewVideo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolutionCreated.push('hls-' + resolution)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dataInput) continue
|
if (!dataInput) continue
|
||||||
|
|
||||||
resolutionCreated.push(resolution)
|
|
||||||
|
|
||||||
const jobOptions = {
|
const jobOptions = {
|
||||||
priority: await getTranscodingJobPriority(user)
|
priority: await getTranscodingJobPriority(user)
|
||||||
}
|
}
|
||||||
|
@ -281,14 +296,14 @@ async function createLowerResolutionsJobs (options: {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolutionCreated.length === 0) {
|
if (resolutionCreated.length === 0) {
|
||||||
logger.info('No transcoding jobs created for video %s (no resolutions).', video.uuid)
|
logger.info('No transcoding jobs created for video %s (no resolutions).', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
'New resolutions %s transcoding jobs created for video %s and origin file resolution of %d.', type, video.uuid, videoFileResolution,
|
'New resolutions %s transcoding jobs created for video %s and origin file resolution of %d.', type, video.uuid, videoFileResolution,
|
||||||
{ resolutionCreated }
|
{ resolutionCreated, ...lTags(video.uuid) }
|
||||||
)
|
)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue