aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorThéo Le Calvar <tlc@kher.nl>2021-04-03 23:51:37 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-04-09 15:53:18 +0200
commit43f7a43ca442de0c838cb15c55ab8845f3eec950 (patch)
tree703ce0c6e4df4889fcfeb7e817749219cb4ba8c0 /server/helpers
parent5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da (diff)
downloadPeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.tar.gz
PeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.tar.zst
PeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.zip
add option for transcode plugins to add video filters and make all options optional
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts19
1 files changed, 11 insertions, 8 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 32bd3e44a..685a35886 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -3,7 +3,7 @@ import * as ffmpeg from 'fluent-ffmpeg'
3import { readFile, remove, writeFile } from 'fs-extra' 3import { readFile, remove, writeFile } from 'fs-extra'
4import { dirname, join } from 'path' 4import { dirname, join } from 'path'
5import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' 5import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
6import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos' 6import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos'
7import { CONFIG } from '../initializers/config' 7import { CONFIG } from '../initializers/config'
8import { execPromise, promisify0 } from './core-utils' 8import { execPromise, promisify0 } from './core-utils'
9import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' 9import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
@@ -277,8 +277,7 @@ async function getLiveTranscodingCommand (options: {
277 logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult) 277 logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult)
278 278
279 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`) 279 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
280 command.addInputOptions(builderResult.result.inputOptions) 280 applyEncoderOptions(command, builderResult.result)
281 command.addOutputOptions(builderResult.result.outputOptions)
282 } 281 }
283 282
284 { 283 {
@@ -295,8 +294,7 @@ async function getLiveTranscodingCommand (options: {
295 logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult) 294 logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult)
296 295
297 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) 296 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
298 command.addInputOptions(builderResult.result.inputOptions) 297 applyEncoderOptions(command, builderResult.result)
299 command.addOutputOptions(builderResult.result.outputOptions)
300 } 298 }
301 299
302 varStreamMap.push(`v:${i},a:${i}`) 300 varStreamMap.push(`v:${i},a:${i}`)
@@ -606,9 +604,7 @@ async function presetVideo (
606 } else if (streamType === 'audio') { 604 } else if (streamType === 'audio') {
607 localCommand.audioCodec(builderResult.encoder) 605 localCommand.audioCodec(builderResult.encoder)
608 } 606 }
609 607 applyEncoderOptions(localCommand, builderResult.result)
610 command.addInputOptions(builderResult.result.inputOptions)
611 command.addOutputOptions(builderResult.result.outputOptions)
612 addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps }) 608 addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps })
613 } 609 }
614 610
@@ -629,6 +625,13 @@ function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
629 .noVideo() 625 .noVideo()
630} 626}
631 627
628function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand {
629 return command
630 .inputOptions(options.inputOptions ?? [])
631 .videoFilters(options.videoFilters ?? [])
632 .outputOptions(options.outputOptions ?? [])
633}
634
632// --------------------------------------------------------------------------- 635// ---------------------------------------------------------------------------
633// Utils 636// Utils
634// --------------------------------------------------------------------------- 637// ---------------------------------------------------------------------------