diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-12 16:09:02 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-10-24 14:48:24 +0200 |
commit | 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (patch) | |
tree | e7f1d12ef5dae1e1142c3a8d0b681c1dbbb0de10 /server/helpers | |
parent | 38a3ccc7f8ad0ea94362b58c732af7c387ab46be (diff) | |
download | PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.gz PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.zst PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.zip |
Put private videos under a specific subdirectory
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/ffmpeg/ffmpeg-vod.ts | 13 | ||||
-rw-r--r-- | server/helpers/upload.ts | 6 | ||||
-rw-r--r-- | server/helpers/webtorrent.ts | 7 |
3 files changed, 21 insertions, 5 deletions
diff --git a/server/helpers/ffmpeg/ffmpeg-vod.ts b/server/helpers/ffmpeg/ffmpeg-vod.ts index 7a81a1313..d84703eb9 100644 --- a/server/helpers/ffmpeg/ffmpeg-vod.ts +++ b/server/helpers/ffmpeg/ffmpeg-vod.ts | |||
@@ -1,14 +1,15 @@ | |||
1 | import { MutexInterface } from 'async-mutex' | ||
1 | import { Job } from 'bullmq' | 2 | import { Job } from 'bullmq' |
2 | import { FfmpegCommand } from 'fluent-ffmpeg' | 3 | import { FfmpegCommand } from 'fluent-ffmpeg' |
3 | import { readFile, writeFile } from 'fs-extra' | 4 | import { readFile, writeFile } from 'fs-extra' |
4 | import { dirname } from 'path' | 5 | import { dirname } from 'path' |
6 | import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' | ||
5 | import { pick } from '@shared/core-utils' | 7 | import { pick } from '@shared/core-utils' |
6 | import { AvailableEncoders, VideoResolution } from '@shared/models' | 8 | import { AvailableEncoders, VideoResolution } from '@shared/models' |
7 | import { logger, loggerTagsFactory } from '../logger' | 9 | import { logger, loggerTagsFactory } from '../logger' |
8 | import { getFFmpeg, runCommand } from './ffmpeg-commons' | 10 | import { getFFmpeg, runCommand } from './ffmpeg-commons' |
9 | import { presetCopy, presetOnlyAudio, presetVOD } from './ffmpeg-presets' | 11 | import { presetCopy, presetOnlyAudio, presetVOD } from './ffmpeg-presets' |
10 | import { computeFPS, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from './ffprobe-utils' | 12 | import { computeFPS, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from './ffprobe-utils' |
11 | import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' | ||
12 | 13 | ||
13 | const lTags = loggerTagsFactory('ffmpeg') | 14 | const lTags = loggerTagsFactory('ffmpeg') |
14 | 15 | ||
@@ -22,6 +23,10 @@ interface BaseTranscodeVODOptions { | |||
22 | inputPath: string | 23 | inputPath: string |
23 | outputPath: string | 24 | outputPath: string |
24 | 25 | ||
26 | // Will be released after the ffmpeg started | ||
27 | // To prevent a bug where the input file does not exist anymore when running ffmpeg | ||
28 | inputFileMutexReleaser: MutexInterface.Releaser | ||
29 | |||
25 | availableEncoders: AvailableEncoders | 30 | availableEncoders: AvailableEncoders |
26 | profile: string | 31 | profile: string |
27 | 32 | ||
@@ -94,6 +99,12 @@ async function transcodeVOD (options: TranscodeVODOptions) { | |||
94 | 99 | ||
95 | command = await builders[options.type](command, options) | 100 | command = await builders[options.type](command, options) |
96 | 101 | ||
102 | command.on('start', () => { | ||
103 | setTimeout(() => { | ||
104 | options.inputFileMutexReleaser() | ||
105 | }, 1000) | ||
106 | }) | ||
107 | |||
97 | await runCommand({ command, job: options.job }) | 108 | await runCommand({ command, job: options.job }) |
98 | 109 | ||
99 | await fixHLSPlaylistIfNeeded(options) | 110 | await fixHLSPlaylistIfNeeded(options) |
diff --git a/server/helpers/upload.ts b/server/helpers/upload.ts index 3cb17edd0..f5f476913 100644 --- a/server/helpers/upload.ts +++ b/server/helpers/upload.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { RESUMABLE_UPLOAD_DIRECTORY } from '../initializers/constants' | 2 | import { DIRECTORIES } from '@server/initializers/constants' |
3 | 3 | ||
4 | function getResumableUploadPath (filename?: string) { | 4 | function getResumableUploadPath (filename?: string) { |
5 | if (filename) return join(RESUMABLE_UPLOAD_DIRECTORY, filename) | 5 | if (filename) return join(DIRECTORIES.RESUMABLE_UPLOAD, filename) |
6 | 6 | ||
7 | return RESUMABLE_UPLOAD_DIRECTORY | 7 | return DIRECTORIES.RESUMABLE_UPLOAD |
8 | } | 8 | } |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 88bdb16b6..6d87c74f7 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -164,7 +164,10 @@ function generateMagnetUri ( | |||
164 | ) { | 164 | ) { |
165 | const xs = videoFile.getTorrentUrl() | 165 | const xs = videoFile.getTorrentUrl() |
166 | const announce = trackerUrls | 166 | const announce = trackerUrls |
167 | let urlList = [ videoFile.getFileUrl(video) ] | 167 | |
168 | let urlList = video.requiresAuth(video.uuid) | ||
169 | ? [] | ||
170 | : [ videoFile.getFileUrl(video) ] | ||
168 | 171 | ||
169 | const redundancies = videoFile.RedundancyVideos | 172 | const redundancies = videoFile.RedundancyVideos |
170 | if (isArray(redundancies)) urlList = urlList.concat(redundancies.map(r => r.fileUrl)) | 173 | if (isArray(redundancies)) urlList = urlList.concat(redundancies.map(r => r.fileUrl)) |
@@ -240,6 +243,8 @@ function buildAnnounceList () { | |||
240 | } | 243 | } |
241 | 244 | ||
242 | function buildUrlList (video: MVideo, videoFile: MVideoFile) { | 245 | function buildUrlList (video: MVideo, videoFile: MVideoFile) { |
246 | if (video.requiresAuth(video.uuid)) return [] | ||
247 | |||
243 | return [ videoFile.getFileUrl(video) ] | 248 | return [ videoFile.getFileUrl(video) ] |
244 | } | 249 | } |
245 | 250 | ||