diff options
author | Théo Le Calvar <tlc@kher.nl> | 2021-04-03 23:51:37 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-09 15:53:18 +0200 |
commit | 43f7a43ca442de0c838cb15c55ab8845f3eec950 (patch) | |
tree | 703ce0c6e4df4889fcfeb7e817749219cb4ba8c0 | |
parent | 5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da (diff) | |
download | PeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.tar.gz PeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.tar.zst PeerTube-43f7a43ca442de0c838cb15c55ab8845f3eec950.zip |
add option for transcode plugins to add video filters and make all options optional
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 19 | ||||
-rw-r--r-- | shared/models/videos/video-transcoding.model.ts | 5 |
2 files changed, 14 insertions, 10 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' | |||
3 | import { readFile, remove, writeFile } from 'fs-extra' | 3 | import { readFile, remove, writeFile } from 'fs-extra' |
4 | import { dirname, join } from 'path' | 4 | import { dirname, join } from 'path' |
5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' | 5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' |
6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos' | 6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderOptions, EncoderProfile, VideoResolution } from '../../shared/models/videos' |
7 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
8 | import { execPromise, promisify0 } from './core-utils' | 8 | import { execPromise, promisify0 } from './core-utils' |
9 | import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' | 9 | import { 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 | ||
628 | function 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 | // --------------------------------------------------------------------------- |
diff --git a/shared/models/videos/video-transcoding.model.ts b/shared/models/videos/video-transcoding.model.ts index 52b468a96..ffb0115dc 100644 --- a/shared/models/videos/video-transcoding.model.ts +++ b/shared/models/videos/video-transcoding.model.ts | |||
@@ -12,8 +12,9 @@ export type EncoderOptionsBuilder = (params: { | |||
12 | export interface EncoderOptions { | 12 | export interface EncoderOptions { |
13 | copy?: boolean // Copy stream? Default to false | 13 | copy?: boolean // Copy stream? Default to false |
14 | 14 | ||
15 | inputOptions: string[] | 15 | inputOptions?: string[] |
16 | outputOptions: string[] | 16 | videoFilters?: string[] |
17 | outputOptions?: string[] | ||
17 | } | 18 | } |
18 | 19 | ||
19 | // All our encoders | 20 | // All our encoders |