From 679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Aug 2021 13:35:25 +0200 Subject: Improve target bitrate calculation --- server/lib/job-queue/handlers/video-file-import.ts | 10 +++++----- server/lib/job-queue/handlers/video-import.ts | 6 +++--- server/lib/job-queue/handlers/video-live-ending.ts | 4 ++-- server/lib/job-queue/handlers/video-transcoding.ts | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index 4d199f247..2f4abf730 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts @@ -32,7 +32,7 @@ async function processVideoFileImport (job: Bull.Job) { const newResolutionPayload = { type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent', videoUUID: video.uuid, - resolution: data.videoFileResolution, + resolution: data.resolution, isPortraitMode: data.isPortraitMode, copyCodecs: false, isNewVideo: false @@ -51,13 +51,13 @@ export { // --------------------------------------------------------------------------- async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { - const { videoFileResolution } = await getVideoFileResolution(inputFilePath) + const { resolution } = await getVideoFileResolution(inputFilePath) const { size } = await stat(inputFilePath) const fps = await getVideoFileFPS(inputFilePath) const fileExt = getLowercaseExtension(inputFilePath) - const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === videoFileResolution) + const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === resolution) if (currentVideoFile) { // Remove old file and old torrent @@ -69,9 +69,9 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { } const newVideoFile = new VideoFileModel({ - resolution: videoFileResolution, + resolution, extname: fileExt, - filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), + filename: generateWebTorrentVideoFilename(resolution, fileExt), size, fps, videoId: video.id diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 5fd2039b1..fec553f2b 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -114,7 +114,7 @@ async function processFile (downloader: () => Promise, videoImport: MVid throw new Error('The user video quota is exceeded with this video to import.') } - const { videoFileResolution } = await getVideoFileResolution(tempVideoPath) + const { resolution } = await getVideoFileResolution(tempVideoPath) const fps = await getVideoFileFPS(tempVideoPath) const duration = await getDurationFromVideoFile(tempVideoPath) @@ -122,9 +122,9 @@ async function processFile (downloader: () => Promise, videoImport: MVid const fileExt = getLowercaseExtension(tempVideoPath) const videoFileData = { extname: fileExt, - resolution: videoFileResolution, + resolution, size: stats.size, - filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), + filename: generateWebTorrentVideoFilename(resolution, fileExt), fps, videoId: videoImport.videoId } diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 386ccdc7b..aa5bd573a 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -96,12 +96,12 @@ async function saveLive (video: MVideo, live: MVideoLive, streamingPlaylist: MSt const probe = await ffprobePromise(concatenatedTsFilePath) const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe) - const { videoFileResolution, isPortraitMode } = await getVideoFileResolution(concatenatedTsFilePath, probe) + const { resolution, isPortraitMode } = await getVideoFileResolution(concatenatedTsFilePath, probe) const outputPath = await generateHlsPlaylistResolutionFromTS({ video: videoWithFiles, concatenatedTsFilePath, - resolution: videoFileResolution, + resolution, isPortraitMode, isAAC: audioStream?.codec_name === 'aac' }) diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 2abb351ce..876d1460c 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -136,7 +136,7 @@ async function onVideoFileOptimizer ( if (videoArg === undefined) return undefined // Outside the transaction (IO on disk) - const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution() + const { resolution, isPortraitMode } = await videoArg.getMaxQualityResolution() // Maybe the video changed in database, refresh it const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid) @@ -155,7 +155,7 @@ async function onVideoFileOptimizer ( }) const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload) - const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, videoFileResolution, isPortraitMode, 'webtorrent') + const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, resolution, isPortraitMode, 'webtorrent') if (!hasHls && !hasNewResolutions) { // No transcoding to do, it's now published -- cgit v1.2.3