From 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Oct 2022 16:09:02 +0200 Subject: Put private videos under a specific subdirectory --- server/helpers/ffmpeg/ffmpeg-vod.ts | 13 ++++++++++++- server/helpers/upload.ts | 6 +++--- server/helpers/webtorrent.ts | 7 ++++++- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'server/helpers') 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 @@ +import { MutexInterface } from 'async-mutex' import { Job } from 'bullmq' import { FfmpegCommand } from 'fluent-ffmpeg' import { readFile, writeFile } from 'fs-extra' import { dirname } from 'path' +import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' import { pick } from '@shared/core-utils' import { AvailableEncoders, VideoResolution } from '@shared/models' import { logger, loggerTagsFactory } from '../logger' import { getFFmpeg, runCommand } from './ffmpeg-commons' import { presetCopy, presetOnlyAudio, presetVOD } from './ffmpeg-presets' import { computeFPS, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from './ffprobe-utils' -import { VIDEO_TRANSCODING_FPS } from '@server/initializers/constants' const lTags = loggerTagsFactory('ffmpeg') @@ -22,6 +23,10 @@ interface BaseTranscodeVODOptions { inputPath: string outputPath: string + // Will be released after the ffmpeg started + // To prevent a bug where the input file does not exist anymore when running ffmpeg + inputFileMutexReleaser: MutexInterface.Releaser + availableEncoders: AvailableEncoders profile: string @@ -94,6 +99,12 @@ async function transcodeVOD (options: TranscodeVODOptions) { command = await builders[options.type](command, options) + command.on('start', () => { + setTimeout(() => { + options.inputFileMutexReleaser() + }, 1000) + }) + await runCommand({ command, job: options.job }) 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 @@ import { join } from 'path' -import { RESUMABLE_UPLOAD_DIRECTORY } from '../initializers/constants' +import { DIRECTORIES } from '@server/initializers/constants' function getResumableUploadPath (filename?: string) { - if (filename) return join(RESUMABLE_UPLOAD_DIRECTORY, filename) + if (filename) return join(DIRECTORIES.RESUMABLE_UPLOAD, filename) - return RESUMABLE_UPLOAD_DIRECTORY + return DIRECTORIES.RESUMABLE_UPLOAD } // --------------------------------------------------------------------------- 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 ( ) { const xs = videoFile.getTorrentUrl() const announce = trackerUrls - let urlList = [ videoFile.getFileUrl(video) ] + + let urlList = video.requiresAuth(video.uuid) + ? [] + : [ videoFile.getFileUrl(video) ] const redundancies = videoFile.RedundancyVideos if (isArray(redundancies)) urlList = urlList.concat(redundancies.map(r => r.fileUrl)) @@ -240,6 +243,8 @@ function buildAnnounceList () { } function buildUrlList (video: MVideo, videoFile: MVideoFile) { + if (video.requiresAuth(video.uuid)) return [] + return [ videoFile.getFileUrl(video) ] } -- cgit v1.2.3