add option for transcode plugins to add video filters and make all options optional
This commit is contained in:
parent
5fb7cfbac5
commit
43f7a43ca4
|
@ -3,7 +3,7 @@ import * as ffmpeg from 'fluent-ffmpeg'
|
||||||
import { readFile, remove, writeFile } from 'fs-extra'
|
import { readFile, remove, writeFile } from 'fs-extra'
|
||||||
import { dirname, join } from 'path'
|
import { dirname, join } from 'path'
|
||||||
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
|
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
|
||||||
import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos'
|
import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
import { execPromise, promisify0 } from './core-utils'
|
import { execPromise, promisify0 } from './core-utils'
|
||||||
import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
|
import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
|
||||||
|
@ -277,8 +277,7 @@ async function getLiveTranscodingCommand (options: {
|
||||||
logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult)
|
logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult)
|
||||||
|
|
||||||
command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
|
command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
|
||||||
command.addInputOptions(builderResult.result.inputOptions)
|
applyEncoderOptions(command, builderResult.result)
|
||||||
command.addOutputOptions(builderResult.result.outputOptions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -295,8 +294,7 @@ async function getLiveTranscodingCommand (options: {
|
||||||
logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult)
|
logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult)
|
||||||
|
|
||||||
command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
|
command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
|
||||||
command.addInputOptions(builderResult.result.inputOptions)
|
applyEncoderOptions(command, builderResult.result)
|
||||||
command.addOutputOptions(builderResult.result.outputOptions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
varStreamMap.push(`v:${i},a:${i}`)
|
varStreamMap.push(`v:${i},a:${i}`)
|
||||||
|
@ -606,9 +604,7 @@ async function presetVideo (
|
||||||
} else if (streamType === 'audio') {
|
} else if (streamType === 'audio') {
|
||||||
localCommand.audioCodec(builderResult.encoder)
|
localCommand.audioCodec(builderResult.encoder)
|
||||||
}
|
}
|
||||||
|
applyEncoderOptions(localCommand, builderResult.result)
|
||||||
command.addInputOptions(builderResult.result.inputOptions)
|
|
||||||
command.addOutputOptions(builderResult.result.outputOptions)
|
|
||||||
addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps })
|
addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,6 +625,13 @@ function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
|
||||||
.noVideo()
|
.noVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand {
|
||||||
|
return command
|
||||||
|
.inputOptions(options.inputOptions ?? [])
|
||||||
|
.videoFilters(options.videoFilters ?? [])
|
||||||
|
.outputOptions(options.outputOptions ?? [])
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Utils
|
// Utils
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -12,8 +12,9 @@ export type EncoderOptionsBuilder = (params: {
|
||||||
export interface EncoderOptions {
|
export interface EncoderOptions {
|
||||||
copy?: boolean // Copy stream? Default to false
|
copy?: boolean // Copy stream? Default to false
|
||||||
|
|
||||||
inputOptions: string[]
|
inputOptions?: string[]
|
||||||
outputOptions: string[]
|
videoFilters?: string[]
|
||||||
|
outputOptions?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// All our encoders
|
// All our encoders
|
||||||
|
|
Loading…
Reference in New Issue