aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/plugins/register-helpers.ts4
-rw-r--r--shared/models/plugins/plugin-transcoding-manager.model.ts2
-rw-r--r--support/doc/plugins/guide.md88
3 files changed, 94 insertions, 0 deletions
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index 3a38a4835..1f2a88c27 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -438,6 +438,10 @@ export class RegisterHelpers {
438 438
439 addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number) { 439 addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number) {
440 return addEncoderPriority('vod', streamType, encoder, priority) 440 return addEncoderPriority('vod', streamType, encoder, priority)
441 },
442
443 removeAllProfilesAndEncoderPriorities () {
444 return self.reinitTranscodingProfilesAndEncoders(self.npmName)
441 } 445 }
442 } 446 }
443 } 447 }
diff --git a/shared/models/plugins/plugin-transcoding-manager.model.ts b/shared/models/plugins/plugin-transcoding-manager.model.ts
index ff89687e9..7dfb51ddf 100644
--- a/shared/models/plugins/plugin-transcoding-manager.model.ts
+++ b/shared/models/plugins/plugin-transcoding-manager.model.ts
@@ -8,4 +8,6 @@ export interface PluginTranscodingManager {
8 addLiveEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void 8 addLiveEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void
9 9
10 addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void 10 addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void
11
12 removeAllProfilesAndEncoderPriorities()
11} 13}
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 0d35820e5..9739d117a 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -22,6 +22,7 @@
22 - [Translate](#translate) 22 - [Translate](#translate)
23 - [Get public settings](#get-public-settings) 23 - [Get public settings](#get-public-settings)
24 - [Add custom fields to video form](#add-custom-fields-to-video-form) 24 - [Add custom fields to video form](#add-custom-fields-to-video-form)
25 - [Add new transcoding profiles](#add-new-transcoding-profiles)
25 - [Publishing](#publishing) 26 - [Publishing](#publishing)
26- [Write a plugin/theme](#write-a-plugintheme) 27- [Write a plugin/theme](#write-a-plugintheme)
27 - [Clone the quickstart repository](#clone-the-quickstart-repository) 28 - [Clone the quickstart repository](#clone-the-quickstart-repository)
@@ -440,7 +441,94 @@ async function register ({
440 } 441 }
441 }) 442 })
442} 443}
444```
445
446#### Add new transcoding profiles
447
448Adding transcoding profiles allow admins to change ffmpeg encoding parameters and/or encoders.
449A transcoding profile has to be chosen by the admin of the instance using the admin configuration.
443 450
451```js
452async function register ({
453 transcodingManager
454}) {
455
456 // Adapt bitrate when using libx264 encoder
457 {
458 const builder = (options) => {
459 const { input, resolution, fps, streamNum } = options
460
461 const streamString = streamNum ? ':' + streamNum : ''
462
463 // You can also return a promise
464 return {
465 outputOptions: [
466 // Use a custom bitrate
467 '-b' + streamString + ' 10K'
468 ]
469 }
470 }
471
472 const encoder = 'libx264'
473 const profileName = 'low-quality'
474
475 // Support this profile for VOD transcoding
476 transcodingManager.addVODProfile(encoder, profileName, builder)
477
478 // And/Or support this profile for live transcoding
479 transcodingManager.addLiveProfile(encoder, profileName, builder)
480 }
481
482 {
483 const builder = (options) => {
484 const { streamNum } = options
485
486 const streamString = streamNum ? ':' + streamNum : ''
487
488 // Always copy stream when PeerTube use libfdk_aac or aac encoders
489 return {
490 copy: true
491 }
492 }
493
494 const profileName = 'copy-audio'
495
496 for (const encoder of [ 'libfdk_aac', 'aac' ]) {
497 transcodingManager.addVODProfile(encoder, profileName, builder)
498 }
499 }
500```
501
502PeerTube will try different encoders depending on their priority.
503If the encoder is not available in the current transcoding profile or in ffmpeg, it tries the next one.
504Plugins can change the order of these encoders and add their custom encoders:
505
506```js
507async function register ({
508 transcodingManager
509}) {
510
511 // Adapt bitrate when using libx264 encoder
512 {
513 const builder = () => {
514 return {
515 outputOptions: []
516 }
517 }
518
519 // Support libopus and libvpx-vp9 encoders, just for the example (PeerTube player is only compatible with h264/aac)
520 transcodingManager.addVODProfile('libopus', 'test-vod-profile', builder)
521
522 // Default priorities are ~100
523 // Lowest priority = 1
524 transcodingManager.addVODEncoderPriority('audio', 'libopus', 1000)
525
526 transcodingManager.addVODProfile('libvpx-vp9', 'test-vod-profile', builder)
527 transcodingManager.addVODEncoderPriority('video', 'libvpx-vp9', 1000)
528
529 transcodingManager.addLiveProfile('libopus', 'test-live-profile', builder)
530 transcodingManager.addLiveEncoderPriority('audio', 'libopus', 1000)
531 }
444``` 532```
445 533
446 534