aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 13:35:25 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 14:13:26 +0200
commit679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch)
tree03abf589275db05e5b1fa1c89f57049cd807324a /server/lib/job-queue/handlers
parentc826f34a45757b324a20f71665b44ed10e6953b5 (diff)
downloadPeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip
Improve target bitrate calculation
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts10
-rw-r--r--server/lib/job-queue/handlers/video-import.ts6
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts4
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts4
4 files changed, 12 insertions, 12 deletions
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) {
32 const newResolutionPayload = { 32 const newResolutionPayload = {
33 type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent', 33 type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent',
34 videoUUID: video.uuid, 34 videoUUID: video.uuid,
35 resolution: data.videoFileResolution, 35 resolution: data.resolution,
36 isPortraitMode: data.isPortraitMode, 36 isPortraitMode: data.isPortraitMode,
37 copyCodecs: false, 37 copyCodecs: false,
38 isNewVideo: false 38 isNewVideo: false
@@ -51,13 +51,13 @@ export {
51// --------------------------------------------------------------------------- 51// ---------------------------------------------------------------------------
52 52
53async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { 53async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {
54 const { videoFileResolution } = await getVideoFileResolution(inputFilePath) 54 const { resolution } = await getVideoFileResolution(inputFilePath)
55 const { size } = await stat(inputFilePath) 55 const { size } = await stat(inputFilePath)
56 const fps = await getVideoFileFPS(inputFilePath) 56 const fps = await getVideoFileFPS(inputFilePath)
57 57
58 const fileExt = getLowercaseExtension(inputFilePath) 58 const fileExt = getLowercaseExtension(inputFilePath)
59 59
60 const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === videoFileResolution) 60 const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === resolution)
61 61
62 if (currentVideoFile) { 62 if (currentVideoFile) {
63 // Remove old file and old torrent 63 // Remove old file and old torrent
@@ -69,9 +69,9 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {
69 } 69 }
70 70
71 const newVideoFile = new VideoFileModel({ 71 const newVideoFile = new VideoFileModel({
72 resolution: videoFileResolution, 72 resolution,
73 extname: fileExt, 73 extname: fileExt,
74 filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), 74 filename: generateWebTorrentVideoFilename(resolution, fileExt),
75 size, 75 size,
76 fps, 76 fps,
77 videoId: video.id 77 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<string>, videoImport: MVid
114 throw new Error('The user video quota is exceeded with this video to import.') 114 throw new Error('The user video quota is exceeded with this video to import.')
115 } 115 }
116 116
117 const { videoFileResolution } = await getVideoFileResolution(tempVideoPath) 117 const { resolution } = await getVideoFileResolution(tempVideoPath)
118 const fps = await getVideoFileFPS(tempVideoPath) 118 const fps = await getVideoFileFPS(tempVideoPath)
119 const duration = await getDurationFromVideoFile(tempVideoPath) 119 const duration = await getDurationFromVideoFile(tempVideoPath)
120 120
@@ -122,9 +122,9 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid
122 const fileExt = getLowercaseExtension(tempVideoPath) 122 const fileExt = getLowercaseExtension(tempVideoPath)
123 const videoFileData = { 123 const videoFileData = {
124 extname: fileExt, 124 extname: fileExt,
125 resolution: videoFileResolution, 125 resolution,
126 size: stats.size, 126 size: stats.size,
127 filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), 127 filename: generateWebTorrentVideoFilename(resolution, fileExt),
128 fps, 128 fps,
129 videoId: videoImport.videoId 129 videoId: videoImport.videoId
130 } 130 }
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
96 const probe = await ffprobePromise(concatenatedTsFilePath) 96 const probe = await ffprobePromise(concatenatedTsFilePath)
97 const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe) 97 const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe)
98 98
99 const { videoFileResolution, isPortraitMode } = await getVideoFileResolution(concatenatedTsFilePath, probe) 99 const { resolution, isPortraitMode } = await getVideoFileResolution(concatenatedTsFilePath, probe)
100 100
101 const outputPath = await generateHlsPlaylistResolutionFromTS({ 101 const outputPath = await generateHlsPlaylistResolutionFromTS({
102 video: videoWithFiles, 102 video: videoWithFiles,
103 concatenatedTsFilePath, 103 concatenatedTsFilePath,
104 resolution: videoFileResolution, 104 resolution,
105 isPortraitMode, 105 isPortraitMode,
106 isAAC: audioStream?.codec_name === 'aac' 106 isAAC: audioStream?.codec_name === 'aac'
107 }) 107 })
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 (
136 if (videoArg === undefined) return undefined 136 if (videoArg === undefined) return undefined
137 137
138 // Outside the transaction (IO on disk) 138 // Outside the transaction (IO on disk)
139 const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution() 139 const { resolution, isPortraitMode } = await videoArg.getMaxQualityResolution()
140 140
141 // Maybe the video changed in database, refresh it 141 // Maybe the video changed in database, refresh it
142 const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid) 142 const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid)
@@ -155,7 +155,7 @@ async function onVideoFileOptimizer (
155 }) 155 })
156 const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload) 156 const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload)
157 157
158 const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, videoFileResolution, isPortraitMode, 'webtorrent') 158 const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, resolution, isPortraitMode, 'webtorrent')
159 159
160 if (!hasHls && !hasNewResolutions) { 160 if (!hasHls && !hasNewResolutions) {
161 // No transcoding to do, it's now published 161 // No transcoding to do, it's now published