diff options
author | Théo Le Calvar <tlc@kher.nl> | 2021-04-03 18:48:14 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-09 15:53:18 +0200 |
commit | 5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da (patch) | |
tree | 8a253611577988fb71527477ae138be7eaf49c6b | |
parent | d2466f0ac9c9877df10f62b7ac20bc3253a2a84a (diff) | |
download | PeerTube-5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da.tar.gz PeerTube-5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da.tar.zst PeerTube-5fb7cfbac50e2c55f04182e40bc6f84e5dd4a4da.zip |
add support for inputOptions in trancode plugins
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 3 | ||||
-rw-r--r-- | server/lib/video-transcoding-profiles.ts | 12 | ||||
-rw-r--r-- | shared/models/videos/video-transcoding.model.ts | 1 | ||||
-rw-r--r-- | support/doc/plugins/guide.md | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 01c3aa5f7..32bd3e44a 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -277,6 +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 | command.addOutputOptions(builderResult.result.outputOptions) | 281 | command.addOutputOptions(builderResult.result.outputOptions) |
281 | } | 282 | } |
282 | 283 | ||
@@ -294,6 +295,7 @@ async function getLiveTranscodingCommand (options: { | |||
294 | logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult) | 295 | logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult) |
295 | 296 | ||
296 | command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) | 297 | command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) |
298 | command.addInputOptions(builderResult.result.inputOptions) | ||
297 | command.addOutputOptions(builderResult.result.outputOptions) | 299 | command.addOutputOptions(builderResult.result.outputOptions) |
298 | } | 300 | } |
299 | 301 | ||
@@ -605,6 +607,7 @@ async function presetVideo ( | |||
605 | localCommand.audioCodec(builderResult.encoder) | 607 | localCommand.audioCodec(builderResult.encoder) |
606 | } | 608 | } |
607 | 609 | ||
610 | command.addInputOptions(builderResult.result.inputOptions) | ||
608 | command.addOutputOptions(builderResult.result.outputOptions) | 611 | command.addOutputOptions(builderResult.result.outputOptions) |
609 | addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps }) | 612 | addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps }) |
610 | } | 613 | } |
diff --git a/server/lib/video-transcoding-profiles.ts b/server/lib/video-transcoding-profiles.ts index b7f9178c4..d802e2c9d 100644 --- a/server/lib/video-transcoding-profiles.ts +++ b/server/lib/video-transcoding-profiles.ts | |||
@@ -24,9 +24,10 @@ import { VIDEO_TRANSCODING_FPS } from '../initializers/constants' | |||
24 | 24 | ||
25 | const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async ({ input, resolution, fps }) => { | 25 | const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async ({ input, resolution, fps }) => { |
26 | const targetBitrate = await buildTargetBitrate({ input, resolution, fps }) | 26 | const targetBitrate = await buildTargetBitrate({ input, resolution, fps }) |
27 | if (!targetBitrate) return { outputOptions: [ ] } | 27 | if (!targetBitrate) return { inputOptions: [ ], outputOptions: [ ] } |
28 | 28 | ||
29 | return { | 29 | return { |
30 | inputOptions: [ ], | ||
30 | outputOptions: [ | 31 | outputOptions: [ |
31 | `-preset veryfast`, | 32 | `-preset veryfast`, |
32 | `-r ${fps}`, | 33 | `-r ${fps}`, |
@@ -40,6 +41,7 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = async ({ resolution | |||
40 | const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) | 41 | const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) |
41 | 42 | ||
42 | return { | 43 | return { |
44 | inputOptions: [ ], | ||
43 | outputOptions: [ | 45 | outputOptions: [ |
44 | `-preset veryfast`, | 46 | `-preset veryfast`, |
45 | `${buildStreamSuffix('-r:v', streamNum)} ${fps}`, | 47 | `${buildStreamSuffix('-r:v', streamNum)} ${fps}`, |
@@ -55,7 +57,7 @@ const defaultAACOptionsBuilder: EncoderOptionsBuilder = async ({ input, streamNu | |||
55 | 57 | ||
56 | if (await canDoQuickAudioTranscode(input, probe)) { | 58 | if (await canDoQuickAudioTranscode(input, probe)) { |
57 | logger.debug('Copy audio stream %s by AAC encoder.', input) | 59 | logger.debug('Copy audio stream %s by AAC encoder.', input) |
58 | return { copy: true, outputOptions: [] } | 60 | return { copy: true, inputOptions: [ ], outputOptions: [ ] } |
59 | } | 61 | } |
60 | 62 | ||
61 | const parsedAudio = await getAudioStream(input, probe) | 63 | const parsedAudio = await getAudioStream(input, probe) |
@@ -70,14 +72,14 @@ const defaultAACOptionsBuilder: EncoderOptionsBuilder = async ({ input, streamNu | |||
70 | logger.debug('Calculating audio bitrate of %s by AAC encoder.', input, { bitrate: parsedAudio.bitrate, audioCodecName }) | 72 | logger.debug('Calculating audio bitrate of %s by AAC encoder.', input, { bitrate: parsedAudio.bitrate, audioCodecName }) |
71 | 73 | ||
72 | if (bitrate !== undefined && bitrate !== -1) { | 74 | if (bitrate !== undefined && bitrate !== -1) { |
73 | return { outputOptions: [ buildStreamSuffix('-b:a', streamNum), bitrate + 'k' ] } | 75 | return { inputOptions: [ ], outputOptions: [ buildStreamSuffix('-b:a', streamNum), bitrate + 'k' ] } |
74 | } | 76 | } |
75 | 77 | ||
76 | return { outputOptions: [ ] } | 78 | return { inputOptions: [ ], outputOptions: [ ] } |
77 | } | 79 | } |
78 | 80 | ||
79 | const defaultLibFDKAACVODOptionsBuilder: EncoderOptionsBuilder = ({ streamNum }) => { | 81 | const defaultLibFDKAACVODOptionsBuilder: EncoderOptionsBuilder = ({ streamNum }) => { |
80 | return { outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] } | 82 | return { inputOptions: [ ], outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] } |
81 | } | 83 | } |
82 | 84 | ||
83 | // Used to get and update available encoders | 85 | // Used to get and update available encoders |
diff --git a/shared/models/videos/video-transcoding.model.ts b/shared/models/videos/video-transcoding.model.ts index 06b555c16..52b468a96 100644 --- a/shared/models/videos/video-transcoding.model.ts +++ b/shared/models/videos/video-transcoding.model.ts | |||
@@ -12,6 +12,7 @@ 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 | outputOptions: string[] | 16 | outputOptions: string[] |
16 | } | 17 | } |
17 | 18 | ||
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index f5e753b79..18e962c10 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -342,6 +342,7 @@ async function register ({ | |||
342 | 342 | ||
343 | // You can also return a promise | 343 | // You can also return a promise |
344 | return { | 344 | return { |
345 | inputOptions: [], | ||
345 | outputOptions: [ | 346 | outputOptions: [ |
346 | // Use a custom bitrate | 347 | // Use a custom bitrate |
347 | '-b' + streamString + ' 10K' | 348 | '-b' + streamString + ' 10K' |
@@ -392,6 +393,7 @@ async function register ({ | |||
392 | { | 393 | { |
393 | const builder = () => { | 394 | const builder = () => { |
394 | return { | 395 | return { |
396 | inputOptions: [], | ||
395 | outputOptions: [] | 397 | outputOptions: [] |
396 | } | 398 | } |
397 | } | 399 | } |