Fix transcoding error
When transcoding.always_transcode_original_resolution is false
This commit is contained in:
parent
89eda2aab0
commit
29c7319c8a
|
@ -75,21 +75,21 @@ export {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
|
logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job })
|
await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job })
|
||||||
|
|
||||||
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
|
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
|
logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job })
|
await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job })
|
||||||
|
|
||||||
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
|
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,11 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) {
|
async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) {
|
||||||
logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid))
|
logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, fps: payload.fps, job })
|
await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, fps: payload.fps, job })
|
||||||
|
|
||||||
logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video })
|
await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video })
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorren
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) {
|
async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) {
|
||||||
logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid))
|
logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid), { payload })
|
||||||
|
|
||||||
const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid)
|
const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid)
|
||||||
let video: MVideoFullLight
|
let video: MVideoFullLight
|
||||||
|
@ -138,7 +138,7 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg:
|
||||||
inputFileMutexReleaser()
|
inputFileMutexReleaser()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
|
||||||
|
|
||||||
if (payload.deleteWebTorrentFiles === true) {
|
if (payload.deleteWebTorrentFiles === true) {
|
||||||
logger.info('Removing WebTorrent files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid))
|
logger.info('Removing WebTorrent files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid))
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
import { getTranscodingJobPriority } from '../../transcoding-priority'
|
import { getTranscodingJobPriority } from '../../transcoding-priority'
|
||||||
import { canDoQuickTranscode } from '../../transcoding-quick-transcode'
|
import { canDoQuickTranscode } from '../../transcoding-quick-transcode'
|
||||||
import { computeResolutionsToTranscode } from '../../transcoding-resolutions'
|
import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions'
|
||||||
import { AbstractJobBuilder } from './abstract-job-builder'
|
import { AbstractJobBuilder } from './abstract-job-builder'
|
||||||
|
|
||||||
export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
|
export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
|
||||||
|
@ -55,7 +55,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
|
||||||
|
|
||||||
const maxResolution = await isAudioFile(videoFilePath, probe)
|
const maxResolution = await isAudioFile(videoFilePath, probe)
|
||||||
? DEFAULT_AUDIO_RESOLUTION
|
? DEFAULT_AUDIO_RESOLUTION
|
||||||
: resolution
|
: buildOriginalFileResolution(resolution)
|
||||||
|
|
||||||
if (CONFIG.TRANSCODING.HLS.ENABLED === true) {
|
if (CONFIG.TRANSCODING.HLS.ENABLED === true) {
|
||||||
nextTranscodingSequentialJobPayloads.push([
|
nextTranscodingSequentialJobPayloads.push([
|
||||||
|
|
|
@ -2,6 +2,27 @@ import { CONFIG } from '@server/initializers/config'
|
||||||
import { toEven } from '@shared/core-utils'
|
import { toEven } from '@shared/core-utils'
|
||||||
import { VideoResolution } from '@shared/models'
|
import { VideoResolution } from '@shared/models'
|
||||||
|
|
||||||
|
export function buildOriginalFileResolution (inputResolution: number) {
|
||||||
|
if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) {
|
||||||
|
return toEven(inputResolution)
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolutions = computeResolutionsToTranscode({
|
||||||
|
input: inputResolution,
|
||||||
|
type: 'vod',
|
||||||
|
includeInput: false,
|
||||||
|
strictLower: false,
|
||||||
|
// We don't really care about the audio resolution in this context
|
||||||
|
hasAudio: true
|
||||||
|
})
|
||||||
|
|
||||||
|
if (resolutions.length === 0) {
|
||||||
|
return toEven(inputResolution)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.max(...resolutions)
|
||||||
|
}
|
||||||
|
|
||||||
export function computeResolutionsToTranscode (options: {
|
export function computeResolutionsToTranscode (options: {
|
||||||
input: number
|
input: number
|
||||||
type: 'vod' | 'live'
|
type: 'vod' | 'live'
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { copyFile, move, remove, stat } from 'fs-extra'
|
||||||
import { basename, join } from 'path'
|
import { basename, join } from 'path'
|
||||||
import { computeOutputFPS } from '@server/helpers/ffmpeg'
|
import { computeOutputFPS } from '@server/helpers/ffmpeg'
|
||||||
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
|
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
|
||||||
|
import { VideoModel } from '@server/models/video/video'
|
||||||
import { MVideoFile, MVideoFullLight } from '@server/types/models'
|
import { MVideoFile, MVideoFullLight } from '@server/types/models'
|
||||||
import { toEven } from '@shared/core-utils'
|
|
||||||
import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg'
|
import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg'
|
||||||
import { VideoResolution, VideoStorage } from '@shared/models'
|
import { VideoResolution, VideoStorage } from '@shared/models'
|
||||||
import { CONFIG } from '../../initializers/config'
|
import { CONFIG } from '../../initializers/config'
|
||||||
|
@ -13,8 +13,7 @@ import { generateWebTorrentVideoFilename } from '../paths'
|
||||||
import { buildFileMetadata } from '../video-file'
|
import { buildFileMetadata } from '../video-file'
|
||||||
import { VideoPathManager } from '../video-path-manager'
|
import { VideoPathManager } from '../video-path-manager'
|
||||||
import { buildFFmpegVOD } from './shared'
|
import { buildFFmpegVOD } from './shared'
|
||||||
import { computeResolutionsToTranscode } from './transcoding-resolutions'
|
import { buildOriginalFileResolution } from './transcoding-resolutions'
|
||||||
import { VideoModel } from '@server/models/video/video'
|
|
||||||
|
|
||||||
// Optimize the original video file and replace it. The resolution is not changed.
|
// Optimize the original video file and replace it. The resolution is not changed.
|
||||||
export async function optimizeOriginalVideofile (options: {
|
export async function optimizeOriginalVideofile (options: {
|
||||||
|
@ -248,26 +247,3 @@ export async function onWebTorrentVideoFileTranscoding (options: {
|
||||||
mutexReleaser()
|
mutexReleaser()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function buildOriginalFileResolution (inputResolution: number) {
|
|
||||||
if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) {
|
|
||||||
return toEven(inputResolution)
|
|
||||||
}
|
|
||||||
|
|
||||||
const resolutions = computeResolutionsToTranscode({
|
|
||||||
input: inputResolution,
|
|
||||||
type: 'vod',
|
|
||||||
includeInput: false,
|
|
||||||
strictLower: false,
|
|
||||||
// We don't really care about the audio resolution in this context
|
|
||||||
hasAudio: true
|
|
||||||
})
|
|
||||||
|
|
||||||
if (resolutions.length === 0) {
|
|
||||||
return toEven(inputResolution)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.max(...resolutions)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user