aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-18 14:35:08 +0100
committerChocobozzz <me@florianbigard.com>2021-11-18 15:20:57 +0100
commitad5db1044c8599eaaaa2a578b350777ae996b068 (patch)
tree3e003cccf021152405d49b21c6c91b703c8ae96c /server/helpers
parentb46cf4b920984492df598c1b61179acfc7f6f22e (diff)
downloadPeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.gz
PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.zst
PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.zip
Add ability to run transcoding jobs
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/video-transcoding.ts12
-rw-r--r--server/helpers/ffprobe-utils.ts6
-rw-r--r--server/helpers/webtorrent.ts2
3 files changed, 16 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/video-transcoding.ts b/server/helpers/custom-validators/video-transcoding.ts
new file mode 100644
index 000000000..cf792f996
--- /dev/null
+++ b/server/helpers/custom-validators/video-transcoding.ts
@@ -0,0 +1,12 @@
1import { exists } from './misc'
2
3function isValidCreateTranscodingType (value: any) {
4 return exists(value) &&
5 (value === 'hls' || value === 'webtorrent')
6}
7
8// ---------------------------------------------------------------------------
9
10export {
11 isValidCreateTranscodingType
12}
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index 907f13651..e15628e2a 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -206,7 +206,7 @@ async function getVideoStreamFromFile (path: string, existingProbe?: FfprobeData
206 return metadata.streams.find(s => s.codec_type === 'video') || null 206 return metadata.streams.find(s => s.codec_type === 'video') || null
207} 207}
208 208
209function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') { 209function computeLowerResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') {
210 const configResolutions = type === 'vod' 210 const configResolutions = type === 'vod'
211 ? CONFIG.TRANSCODING.RESOLUTIONS 211 ? CONFIG.TRANSCODING.RESOLUTIONS
212 : CONFIG.LIVE.TRANSCODING.RESOLUTIONS 212 : CONFIG.LIVE.TRANSCODING.RESOLUTIONS
@@ -214,7 +214,7 @@ function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod'
214 const resolutionsEnabled: number[] = [] 214 const resolutionsEnabled: number[] = []
215 215
216 // Put in the order we want to proceed jobs 216 // Put in the order we want to proceed jobs
217 const resolutions = [ 217 const resolutions: VideoResolution[] = [
218 VideoResolution.H_NOVIDEO, 218 VideoResolution.H_NOVIDEO,
219 VideoResolution.H_480P, 219 VideoResolution.H_480P,
220 VideoResolution.H_360P, 220 VideoResolution.H_360P,
@@ -327,7 +327,7 @@ export {
327 getVideoFileFPS, 327 getVideoFileFPS,
328 ffprobePromise, 328 ffprobePromise,
329 getClosestFramerateStandard, 329 getClosestFramerateStandard,
330 computeResolutionsToTranscode, 330 computeLowerResolutionsToTranscode,
331 getVideoFileBitrate, 331 getVideoFileBitrate,
332 canDoQuickTranscode, 332 canDoQuickTranscode,
333 canDoQuickVideoTranscode, 333 canDoQuickVideoTranscode,
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index 5e1ea6198..c75c058e4 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -100,7 +100,7 @@ function createTorrentAndSetInfoHash (videoOrPlaylist: MVideo | MStreamingPlayli
100 urlList: buildUrlList(video, videoFile) 100 urlList: buildUrlList(video, videoFile)
101 } 101 }
102 102
103 return VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, videoFile, async videoPath => { 103 return VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(videoOrPlaylist), async videoPath => {
104 const torrentContent = await createTorrentPromise(videoPath, options) 104 const torrentContent = await createTorrentPromise(videoPath, options)
105 105
106 const torrentFilename = generateTorrentFileName(videoOrPlaylist, videoFile.resolution) 106 const torrentFilename = generateTorrentFileName(videoOrPlaylist, videoFile.resolution)