mirror of https://github.com/Chocobozzz/PeerTube
Fix running again transcoding on a video only file
parent
11ae7e2917
commit
a32bf8cd20
|
@ -49,11 +49,14 @@ async function run () {
|
||||||
const dataInput: VideoTranscodingPayload[] = []
|
const dataInput: VideoTranscodingPayload[] = []
|
||||||
const maxResolution = video.getMaxQualityFile().resolution
|
const maxResolution = video.getMaxQualityFile().resolution
|
||||||
|
|
||||||
|
// FIXME: check the file has audio
|
||||||
|
const hasAudio = true
|
||||||
|
|
||||||
// Generate HLS files
|
// Generate HLS files
|
||||||
if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
|
if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
|
||||||
const resolutionsEnabled = options.resolution
|
const resolutionsEnabled = options.resolution
|
||||||
? [ parseInt(options.resolution) ]
|
? [ parseInt(options.resolution) ]
|
||||||
: computeResolutionsToTranscode({ input: maxResolution, type: 'vod', includeInput: true, strictLower: false })
|
: computeResolutionsToTranscode({ input: maxResolution, type: 'vod', includeInput: true, strictLower: false, hasAudio })
|
||||||
|
|
||||||
for (const resolution of resolutionsEnabled) {
|
for (const resolution of resolutionsEnabled) {
|
||||||
dataInput.push({
|
dataInput.push({
|
||||||
|
@ -61,7 +64,7 @@ async function run () {
|
||||||
videoUUID: video.uuid,
|
videoUUID: video.uuid,
|
||||||
resolution,
|
resolution,
|
||||||
|
|
||||||
hasAudio: true,
|
hasAudio,
|
||||||
|
|
||||||
copyCodecs: false,
|
copyCodecs: false,
|
||||||
isNewVideo: false,
|
isNewVideo: false,
|
||||||
|
@ -77,8 +80,7 @@ async function run () {
|
||||||
|
|
||||||
createHLSIfNeeded: true,
|
createHLSIfNeeded: true,
|
||||||
|
|
||||||
// FIXME: check the file has audio
|
hasAudio,
|
||||||
hasAudio: true,
|
|
||||||
|
|
||||||
isNewVideo: false,
|
isNewVideo: false,
|
||||||
resolution: parseInt(options.resolution)
|
resolution: parseInt(options.resolution)
|
||||||
|
|
|
@ -32,9 +32,10 @@ async function createTranscoding (req: express.Request, res: express.Response) {
|
||||||
|
|
||||||
const body: VideoTranscodingCreate = req.body
|
const body: VideoTranscodingCreate = req.body
|
||||||
|
|
||||||
const { resolution: maxResolution, audioStream } = await video.probeMaxQualityFile()
|
const { resolution: maxResolution, hasAudio } = await video.probeMaxQualityFile()
|
||||||
|
|
||||||
const resolutions = await Hooks.wrapObject(
|
const resolutions = await Hooks.wrapObject(
|
||||||
computeResolutionsToTranscode({ input: maxResolution, type: 'vod', includeInput: true, strictLower: false }),
|
computeResolutionsToTranscode({ input: maxResolution, type: 'vod', includeInput: true, strictLower: false, hasAudio }),
|
||||||
'filter:transcoding.manual.resolutions-to-transcode.result',
|
'filter:transcoding.manual.resolutions-to-transcode.result',
|
||||||
body
|
body
|
||||||
)
|
)
|
||||||
|
@ -46,7 +47,6 @@ async function createTranscoding (req: express.Request, res: express.Response) {
|
||||||
video.state = VideoState.TO_TRANSCODE
|
video.state = VideoState.TO_TRANSCODE
|
||||||
await video.save()
|
await video.save()
|
||||||
|
|
||||||
const hasAudio = !!audioStream
|
|
||||||
const childrenResolutions = resolutions.filter(r => r !== maxResolution)
|
const childrenResolutions = resolutions.filter(r => r !== maxResolution)
|
||||||
|
|
||||||
const children = await Bluebird.mapSeries(childrenResolutions, resolution => {
|
const children = await Bluebird.mapSeries(childrenResolutions, resolution => {
|
||||||
|
|
|
@ -96,8 +96,9 @@ function computeResolutionsToTranscode (options: {
|
||||||
type: 'vod' | 'live'
|
type: 'vod' | 'live'
|
||||||
includeInput: boolean
|
includeInput: boolean
|
||||||
strictLower: boolean
|
strictLower: boolean
|
||||||
|
hasAudio: boolean
|
||||||
}) {
|
}) {
|
||||||
const { input, type, includeInput, strictLower } = options
|
const { input, type, includeInput, strictLower, hasAudio } = options
|
||||||
|
|
||||||
const configResolutions = type === 'vod'
|
const configResolutions = type === 'vod'
|
||||||
? CONFIG.TRANSCODING.RESOLUTIONS
|
? CONFIG.TRANSCODING.RESOLUTIONS
|
||||||
|
@ -125,6 +126,8 @@ function computeResolutionsToTranscode (options: {
|
||||||
if (input < resolution) continue
|
if (input < resolution) continue
|
||||||
// We only want lower resolutions than input file
|
// We only want lower resolutions than input file
|
||||||
if (strictLower && input === resolution) continue
|
if (strictLower && input === resolution) continue
|
||||||
|
// Audio resolutio but no audio in the video
|
||||||
|
if (resolution === VideoResolution.H_NOVIDEO && !hasAudio) continue
|
||||||
|
|
||||||
resolutionsEnabled.add(resolution)
|
resolutionsEnabled.add(resolution)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
MergeAudioTranscodingPayload,
|
MergeAudioTranscodingPayload,
|
||||||
NewWebTorrentResolutionTranscodingPayload,
|
NewWebTorrentResolutionTranscodingPayload,
|
||||||
OptimizeTranscodingPayload,
|
OptimizeTranscodingPayload,
|
||||||
VideoResolution,
|
|
||||||
VideoTranscodingPayload
|
VideoTranscodingPayload
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||||
|
@ -281,7 +280,7 @@ async function createLowerResolutionsJobs (options: {
|
||||||
|
|
||||||
// Create transcoding jobs if there are enabled resolutions
|
// Create transcoding jobs if there are enabled resolutions
|
||||||
const resolutionsEnabled = await Hooks.wrapObject(
|
const resolutionsEnabled = await Hooks.wrapObject(
|
||||||
computeResolutionsToTranscode({ input: videoFileResolution, type: 'vod', includeInput: false, strictLower: true }),
|
computeResolutionsToTranscode({ input: videoFileResolution, type: 'vod', includeInput: false, strictLower: true, hasAudio }),
|
||||||
'filter:transcoding.auto.resolutions-to-transcode.result',
|
'filter:transcoding.auto.resolutions-to-transcode.result',
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
|
@ -289,8 +288,6 @@ async function createLowerResolutionsJobs (options: {
|
||||||
const resolutionCreated: string[] = []
|
const resolutionCreated: string[] = []
|
||||||
|
|
||||||
for (const resolution of resolutionsEnabled) {
|
for (const resolution of resolutionsEnabled) {
|
||||||
if (resolution === VideoResolution.H_NOVIDEO && hasAudio === false) continue
|
|
||||||
|
|
||||||
let dataInput: VideoTranscodingPayload
|
let dataInput: VideoTranscodingPayload
|
||||||
|
|
||||||
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED && type === 'webtorrent') {
|
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED && type === 'webtorrent') {
|
||||||
|
|
|
@ -245,7 +245,7 @@ class LiveManager {
|
||||||
)
|
)
|
||||||
|
|
||||||
const allResolutions = await Hooks.wrapObject(
|
const allResolutions = await Hooks.wrapObject(
|
||||||
this.buildAllResolutionsToTranscode(resolution),
|
this.buildAllResolutionsToTranscode(resolution, hasAudio),
|
||||||
'filter:transcoding.auto.resolutions-to-transcode.result',
|
'filter:transcoding.auto.resolutions-to-transcode.result',
|
||||||
{ video }
|
{ video }
|
||||||
)
|
)
|
||||||
|
@ -460,11 +460,11 @@ class LiveManager {
|
||||||
return join(directory, files.sort().reverse()[0])
|
return join(directory, files.sort().reverse()[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildAllResolutionsToTranscode (originResolution: number) {
|
private buildAllResolutionsToTranscode (originResolution: number, hasAudio: boolean) {
|
||||||
const includeInput = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION
|
const includeInput = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION
|
||||||
|
|
||||||
const resolutionsEnabled = CONFIG.LIVE.TRANSCODING.ENABLED
|
const resolutionsEnabled = CONFIG.LIVE.TRANSCODING.ENABLED
|
||||||
? computeResolutionsToTranscode({ input: originResolution, type: 'live', includeInput, strictLower: false })
|
? computeResolutionsToTranscode({ input: originResolution, type: 'live', includeInput, strictLower: false, hasAudio })
|
||||||
: []
|
: []
|
||||||
|
|
||||||
if (resolutionsEnabled.length === 0) {
|
if (resolutionsEnabled.length === 0) {
|
||||||
|
|
|
@ -446,7 +446,15 @@ async function generateHlsPlaylistCommon (options: {
|
||||||
function buildOriginalFileResolution (inputResolution: number) {
|
function buildOriginalFileResolution (inputResolution: number) {
|
||||||
if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) return toEven(inputResolution)
|
if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) return toEven(inputResolution)
|
||||||
|
|
||||||
const resolutions = computeResolutionsToTranscode({ input: inputResolution, type: 'vod', includeInput: false, strictLower: false })
|
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)
|
if (resolutions.length === 0) return toEven(inputResolution)
|
||||||
|
|
||||||
return Math.max(...resolutions)
|
return Math.max(...resolutions)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import { isVideoInPrivateDirectory } from '@server/lib/video-privacy'
|
||||||
import { getServerActor } from '@server/models/application/application'
|
import { getServerActor } from '@server/models/application/application'
|
||||||
import { ModelCache } from '@server/models/model-cache'
|
import { ModelCache } from '@server/models/model-cache'
|
||||||
import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'
|
import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'
|
||||||
import { ffprobePromise, getAudioStream, uuidToShort } from '@shared/extra-utils'
|
import { ffprobePromise, getAudioStream, hasAudioStream, uuidToShort } from '@shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
ResultList,
|
ResultList,
|
||||||
ThumbnailType,
|
ThumbnailType,
|
||||||
|
@ -1751,9 +1751,11 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
const probe = await ffprobePromise(originalFilePath)
|
const probe = await ffprobePromise(originalFilePath)
|
||||||
|
|
||||||
const { audioStream } = await getAudioStream(originalFilePath, probe)
|
const { audioStream } = await getAudioStream(originalFilePath, probe)
|
||||||
|
const hasAudio = await hasAudioStream(originalFilePath, probe)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
audioStream,
|
audioStream,
|
||||||
|
hasAudio,
|
||||||
|
|
||||||
...await getVideoStreamDimensionsInfo(originalFilePath, probe)
|
...await getVideoStreamDimensionsInfo(originalFilePath, probe)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue