Add transcoding custom quality plugin

This commit is contained in:
Chocobozzz 2021-07-30 10:23:21 +02:00
parent d0449b19f8
commit 6f01b590e1
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# PeerTube transcoding custom quality
This plugin creates a transcoding profile in which admins can decide the quality of the transcoding process.

View File

@ -0,0 +1,72 @@
async function register ({
registerSetting,
settingsManager,
transcodingManager
}) {
const defaultCRF = 20
const store = {
crf: await settingsManager.getSetting('crf') || defaultCRF
}
settingsManager.onSettingsChange(settings => {
store.crf = settings['crf']
})
const builderVOD = (options) => {
return {
outputOptions: [
`-r ${options.fps}`,
`-crf ${store.crf}`
]
}
}
const buildLive = (options) => {
return {
outputOptions: [
`${buildStreamSuffix('-r:v', options.streamNum)} ${fps}`,
`-crf ${store.crf}`
]
}
}
registerSetting({
name: 'crf',
label: 'Quality',
type: 'select',
options: [
{ label: 'Default', value: 23 },
{ label: 'Good', value: 20 },
{ label: 'Very good', value: 18 }
],
private: true,
default: defaultCRF
})
const encoder = 'libx264'
const profileName = 'custom-quality'
transcodingManager.addVODProfile(encoder, profileName, builderVOD)
transcodingManager.addLiveProfile(encoder, profileName, buildLive)
}
async function unregister () {
return
}
module.exports = {
register,
unregister
}
// ---------------------------------------------------------------------------
function buildStreamSuffix (base, streamNum) {
if (streamNum !== undefined) {
return `${base}:${streamNum}`
}
return base
}

View File

@ -0,0 +1,20 @@
{
"name": "peertube-plugin-transcoding-custom-quality",
"version": "0.0.1",
"description": "Set a custom quality for transcoding",
"engine": {
"peertube": ">=3.3.0"
},
"keywords": [
"peertube",
"plugin"
],
"homepage": "https://framagit.org/framasoft/peertube/official-plugins/tree/master/peertube-plugin-transcoding-custom-quality",
"author": "Chocobozzz",
"bugs": "https://framagit.org/framasoft/peertube/official-plugins/issues",
"library": "./main.js",
"staticDirs": {},
"css": [ ],
"clientScripts": [],
"translations": {}
}