aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-29 10:23:33 +0100
committerChocobozzz <me@florianbigard.com>2021-01-29 14:05:41 +0100
commit2498aaead1fb4f34c8c375ef9edff33456c4527a (patch)
tree8850d9df5f2452b6532a812de1e5ced224d3f0e6 /support/doc/plugins
parent8a23909fe2381387841d5c355305d16460a27452 (diff)
downloadPeerTube-2498aaead1fb4f34c8c375ef9edff33456c4527a.tar.gz
PeerTube-2498aaead1fb4f34c8c375ef9edff33456c4527a.tar.zst
PeerTube-2498aaead1fb4f34c8c375ef9edff33456c4527a.zip
Add plugin transcoding profile guide
Diffstat (limited to 'support/doc/plugins')
-rw-r--r--support/doc/plugins/guide.md88
1 files changed, 88 insertions, 0 deletions
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