Add transcoding custom quality plugin
This commit is contained in:
		
							
								
								
									
										3
									
								
								peertube-plugin-transcoding-custom-quality/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								peertube-plugin-transcoding-custom-quality/README.md
									
									
									
									
									
										Normal 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. | ||||
							
								
								
									
										72
									
								
								peertube-plugin-transcoding-custom-quality/main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								peertube-plugin-transcoding-custom-quality/main.js
									
									
									
									
									
										Normal 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 | ||||
| } | ||||
							
								
								
									
										20
									
								
								peertube-plugin-transcoding-custom-quality/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								peertube-plugin-transcoding-custom-quality/package.json
									
									
									
									
									
										Normal 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": {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user