Don't block video update on storyboard generation
This commit is contained in:
parent
e8ac84f1b3
commit
8ab6f23a00
|
@ -6,6 +6,7 @@ import {
|
||||||
EncoderProfile,
|
EncoderProfile,
|
||||||
SimpleLogger
|
SimpleLogger
|
||||||
} from '@peertube/peertube-models'
|
} from '@peertube/peertube-models'
|
||||||
|
import { MutexInterface } from 'async-mutex'
|
||||||
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
|
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
|
||||||
|
|
||||||
export interface FFmpegCommandWrapperOptions {
|
export interface FFmpegCommandWrapperOptions {
|
||||||
|
@ -82,7 +83,7 @@ export class FFmpegCommandWrapper {
|
||||||
this.command = undefined
|
this.command = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCommand (input: string) {
|
buildCommand (input: string, inputFileMutexReleaser?: MutexInterface.Releaser) {
|
||||||
if (this.command) throw new Error('Command is already built')
|
if (this.command) throw new Error('Command is already built')
|
||||||
|
|
||||||
// We set cwd explicitly because ffmpeg appears to create temporary files when trancoding which fails in read-only file systems
|
// We set cwd explicitly because ffmpeg appears to create temporary files when trancoding which fails in read-only file systems
|
||||||
|
@ -96,6 +97,12 @@ export class FFmpegCommandWrapper {
|
||||||
this.command.outputOption('-threads ' + this.threads)
|
this.command.outputOption('-threads ' + this.threads)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inputFileMutexReleaser) {
|
||||||
|
this.command.on('start', () => {
|
||||||
|
setTimeout(() => inputFileMutexReleaser(), 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return this.command
|
return this.command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { MutexInterface } from 'async-mutex'
|
||||||
import { FfprobeData } from 'fluent-ffmpeg'
|
import { FfprobeData } from 'fluent-ffmpeg'
|
||||||
import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js'
|
import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js'
|
||||||
import { getVideoStreamDuration } from './ffprobe.js'
|
import { getVideoStreamDuration } from './ffprobe.js'
|
||||||
|
@ -100,6 +101,9 @@ export class FFmpegImage {
|
||||||
path: string
|
path: string
|
||||||
destination: string
|
destination: string
|
||||||
|
|
||||||
|
// Will be released after the ffmpeg started
|
||||||
|
inputFileMutexReleaser: MutexInterface.Releaser
|
||||||
|
|
||||||
sprites: {
|
sprites: {
|
||||||
size: {
|
size: {
|
||||||
width: number
|
width: number
|
||||||
|
|
|
@ -88,19 +88,11 @@ export class FFmpegVOD {
|
||||||
|
|
||||||
this.commandWrapper.debugLog('Will run transcode.', { options })
|
this.commandWrapper.debugLog('Will run transcode.', { options })
|
||||||
|
|
||||||
const command = this.commandWrapper.buildCommand(options.inputPath)
|
this.commandWrapper.buildCommand(options.inputPath, options.inputFileMutexReleaser)
|
||||||
.output(options.outputPath)
|
.output(options.outputPath)
|
||||||
|
|
||||||
await builders[options.type](options)
|
await builders[options.type](options)
|
||||||
|
|
||||||
command.on('start', () => {
|
|
||||||
setTimeout(() => {
|
|
||||||
if (options.inputFileMutexReleaser) {
|
|
||||||
options.inputFileMutexReleaser()
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
})
|
|
||||||
|
|
||||||
await this.commandWrapper.runCommand()
|
await this.commandWrapper.runCommand()
|
||||||
|
|
||||||
await this.fixHLSPlaylistIfNeeded(options)
|
await this.fixHLSPlaylistIfNeeded(options)
|
||||||
|
|
|
@ -81,6 +81,7 @@ async function processGenerateStoryboard (job: Job): Promise<void> {
|
||||||
await ffmpeg.generateStoryboardFromVideo({
|
await ffmpeg.generateStoryboardFromVideo({
|
||||||
destination,
|
destination,
|
||||||
path: videoPath,
|
path: videoPath,
|
||||||
|
inputFileMutexReleaser,
|
||||||
sprites: {
|
sprites: {
|
||||||
size: {
|
size: {
|
||||||
height: spriteHeight,
|
height: spriteHeight,
|
||||||
|
|
Loading…
Reference in New Issue