aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/emailer.ts66
-rw-r--r--server/lib/video-transcoding.ts31
2 files changed, 56 insertions, 41 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 8c06e9751..c4a5a5853 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -100,11 +100,11 @@ class Emailer {
100 `You can view it on ${videoUrl} ` + 100 `You can view it on ${videoUrl} ` +
101 `\n\n` + 101 `\n\n` +
102 `Cheers,\n` + 102 `Cheers,\n` +
103 `PeerTube.` 103 `${CONFIG.EMAIL.BODY.SIGNATURE}`
104 104
105 const emailPayload: EmailPayload = { 105 const emailPayload: EmailPayload = {
106 to, 106 to,
107 subject: channelName + ' just published a new video', 107 subject: CONFIG.EMAIL.OBJECT.PREFIX + channelName + ' just published a new video',
108 text 108 text
109 } 109 }
110 110
@@ -119,11 +119,11 @@ class Emailer {
119 `Your ${followType} ${followingName} has a new subscriber: ${followerName}` + 119 `Your ${followType} ${followingName} has a new subscriber: ${followerName}` +
120 `\n\n` + 120 `\n\n` +
121 `Cheers,\n` + 121 `Cheers,\n` +
122 `PeerTube.` 122 `${CONFIG.EMAIL.BODY.SIGNATURE}`
123 123
124 const emailPayload: EmailPayload = { 124 const emailPayload: EmailPayload = {
125 to, 125 to,
126 subject: 'New follower on your channel ' + followingName, 126 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New follower on your channel ' + followingName,
127 text 127 text
128 } 128 }
129 129
@@ -137,11 +137,11 @@ class Emailer {
137 `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` + 137 `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` +
138 `\n\n` + 138 `\n\n` +
139 `Cheers,\n` + 139 `Cheers,\n` +
140 `PeerTube.` 140 `${CONFIG.EMAIL.BODY.SIGNATURE}`
141 141
142 const emailPayload: EmailPayload = { 142 const emailPayload: EmailPayload = {
143 to, 143 to,
144 subject: 'New instance follower', 144 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New instance follower',
145 text 145 text
146 } 146 }
147 147
@@ -157,11 +157,11 @@ class Emailer {
157 `You can view it on ${videoUrl} ` + 157 `You can view it on ${videoUrl} ` +
158 `\n\n` + 158 `\n\n` +
159 `Cheers,\n` + 159 `Cheers,\n` +
160 `PeerTube.` 160 `${CONFIG.EMAIL.BODY.SIGNATURE}`
161 161
162 const emailPayload: EmailPayload = { 162 const emailPayload: EmailPayload = {
163 to, 163 to,
164 subject: `Your video ${video.name} is published`, 164 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video ${video.name} is published`,
165 text 165 text
166 } 166 }
167 167
@@ -177,11 +177,11 @@ class Emailer {
177 `You can view the imported video on ${videoUrl} ` + 177 `You can view the imported video on ${videoUrl} ` +
178 `\n\n` + 178 `\n\n` +
179 `Cheers,\n` + 179 `Cheers,\n` +
180 `PeerTube.` 180 `${CONFIG.EMAIL.BODY.SIGNATURE}`
181 181
182 const emailPayload: EmailPayload = { 182 const emailPayload: EmailPayload = {
183 to, 183 to,
184 subject: `Your video import ${videoImport.getTargetIdentifier()} is finished`, 184 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} is finished`,
185 text 185 text
186 } 186 }
187 187
@@ -197,11 +197,11 @@ class Emailer {
197 `See your videos import dashboard for more information: ${importUrl}` + 197 `See your videos import dashboard for more information: ${importUrl}` +
198 `\n\n` + 198 `\n\n` +
199 `Cheers,\n` + 199 `Cheers,\n` +
200 `PeerTube.` 200 `${CONFIG.EMAIL.BODY.SIGNATURE}`
201 201
202 const emailPayload: EmailPayload = { 202 const emailPayload: EmailPayload = {
203 to, 203 to,
204 subject: `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, 204 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} encountered an error`,
205 text 205 text
206 } 206 }
207 207
@@ -219,11 +219,11 @@ class Emailer {
219 `You can view it on ${commentUrl} ` + 219 `You can view it on ${commentUrl} ` +
220 `\n\n` + 220 `\n\n` +
221 `Cheers,\n` + 221 `Cheers,\n` +
222 `PeerTube.` 222 `${CONFIG.EMAIL.BODY.SIGNATURE}`
223 223
224 const emailPayload: EmailPayload = { 224 const emailPayload: EmailPayload = {
225 to, 225 to,
226 subject: 'New comment on your video ' + video.name, 226 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New comment on your video ' + video.name,
227 text 227 text
228 } 228 }
229 229
@@ -241,11 +241,11 @@ class Emailer {
241 `You can view the comment on ${commentUrl} ` + 241 `You can view the comment on ${commentUrl} ` +
242 `\n\n` + 242 `\n\n` +
243 `Cheers,\n` + 243 `Cheers,\n` +
244 `PeerTube.` 244 `${CONFIG.EMAIL.BODY.SIGNATURE}`
245 245
246 const emailPayload: EmailPayload = { 246 const emailPayload: EmailPayload = {
247 to, 247 to,
248 subject: 'Mention on video ' + video.name, 248 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Mention on video ' + video.name,
249 text 249 text
250 } 250 }
251 251
@@ -258,11 +258,11 @@ class Emailer {
258 const text = `Hi,\n\n` + 258 const text = `Hi,\n\n` +
259 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + 259 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` +
260 `Cheers,\n` + 260 `Cheers,\n` +
261 `PeerTube.` 261 `${CONFIG.EMAIL.BODY.SIGNATURE}`
262 262
263 const emailPayload: EmailPayload = { 263 const emailPayload: EmailPayload = {
264 to, 264 to,
265 subject: '[PeerTube] Received a video abuse', 265 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Received a video abuse',
266 text 266 text
267 } 267 }
268 268
@@ -281,11 +281,11 @@ class Emailer {
281 `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` + 281 `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` +
282 `\n\n` + 282 `\n\n` +
283 `Cheers,\n` + 283 `Cheers,\n` +
284 `PeerTube.` 284 `${CONFIG.EMAIL.BODY.SIGNATURE}`
285 285
286 const emailPayload: EmailPayload = { 286 const emailPayload: EmailPayload = {
287 to, 287 to,
288 subject: '[PeerTube] An auto-blacklisted video is awaiting review', 288 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'An auto-blacklisted video is awaiting review',
289 text 289 text
290 } 290 }
291 291
@@ -296,11 +296,11 @@ class Emailer {
296 const text = `Hi,\n\n` + 296 const text = `Hi,\n\n` +
297 `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` + 297 `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` +
298 `Cheers,\n` + 298 `Cheers,\n` +
299 `PeerTube.` 299 `${CONFIG.EMAIL.BODY.SIGNATURE}`
300 300
301 const emailPayload: EmailPayload = { 301 const emailPayload: EmailPayload = {
302 to, 302 to,
303 subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST, 303 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New user registration on ' + WEBSERVER.HOST,
304 text 304 text
305 } 305 }
306 306
@@ -318,11 +318,11 @@ class Emailer {
318 blockedString + 318 blockedString +
319 '\n\n' + 319 '\n\n' +
320 'Cheers,\n' + 320 'Cheers,\n' +
321 `PeerTube.` 321 `${CONFIG.EMAIL.BODY.SIGNATURE}`
322 322
323 const emailPayload: EmailPayload = { 323 const emailPayload: EmailPayload = {
324 to, 324 to,
325 subject: `[PeerTube] Video ${videoName} blacklisted`, 325 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${videoName} blacklisted`,
326 text 326 text
327 } 327 }
328 328
@@ -336,11 +336,11 @@ class Emailer {
336 `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` + 336 `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` +
337 '\n\n' + 337 '\n\n' +
338 'Cheers,\n' + 338 'Cheers,\n' +
339 `PeerTube.` 339 `${CONFIG.EMAIL.BODY.SIGNATURE}`
340 340
341 const emailPayload: EmailPayload = { 341 const emailPayload: EmailPayload = {
342 to, 342 to,
343 subject: `[PeerTube] Video ${video.name} unblacklisted`, 343 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${video.name} unblacklisted`,
344 text 344 text
345 } 345 }
346 346
@@ -353,11 +353,11 @@ class Emailer {
353 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + 353 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
354 `If you are not the person who initiated this request, please ignore this email.\n\n` + 354 `If you are not the person who initiated this request, please ignore this email.\n\n` +
355 `Cheers,\n` + 355 `Cheers,\n` +
356 `PeerTube.` 356 `${CONFIG.EMAIL.BODY.SIGNATURE}`
357 357
358 const emailPayload: EmailPayload = { 358 const emailPayload: EmailPayload = {
359 to: [ to ], 359 to: [ to ],
360 subject: 'Reset your PeerTube password', 360 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Reset your password',
361 text 361 text
362 } 362 }
363 363
@@ -370,11 +370,11 @@ class Emailer {
370 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + 370 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` +
371 `If you are not the person who initiated this request, please ignore this email.\n\n` + 371 `If you are not the person who initiated this request, please ignore this email.\n\n` +
372 `Cheers,\n` + 372 `Cheers,\n` +
373 `PeerTube.` 373 `${CONFIG.EMAIL.BODY.SIGNATURE}`
374 374
375 const emailPayload: EmailPayload = { 375 const emailPayload: EmailPayload = {
376 to: [ to ], 376 to: [ to ],
377 subject: 'Verify your PeerTube email', 377 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Verify your email',
378 text 378 text
379 } 379 }
380 380
@@ -390,12 +390,12 @@ class Emailer {
390 blockedString + 390 blockedString +
391 '\n\n' + 391 '\n\n' +
392 'Cheers,\n' + 392 'Cheers,\n' +
393 `PeerTube.` 393 `${CONFIG.EMAIL.BODY.SIGNATURE}`
394 394
395 const to = user.email 395 const to = user.email
396 const emailPayload: EmailPayload = { 396 const emailPayload: EmailPayload = {
397 to: [ to ], 397 to: [ to ],
398 subject: '[PeerTube] Account ' + blockedWord, 398 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Account ' + blockedWord,
399 text 399 text
400 } 400 }
401 401
@@ -415,7 +415,7 @@ class Emailer {
415 fromDisplayName: fromEmail, 415 fromDisplayName: fromEmail,
416 replyTo: fromEmail, 416 replyTo: fromEmail,
417 to: [ CONFIG.ADMIN.EMAIL ], 417 to: [ CONFIG.ADMIN.EMAIL ],
418 subject: '[PeerTube] Contact form submitted', 418 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Contact form submitted',
419 text 419 text
420 } 420 }
421 421
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index 0fe0ff12a..d6b6b251a 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,6 +1,6 @@
1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' 1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
2import { join } from 'path' 2import { join } from 'path'
3import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils'
4import { ensureDir, move, remove, stat } from 'fs-extra' 4import { ensureDir, move, remove, stat } from 'fs-extra'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { VideoResolution } from '../../shared/models/videos' 6import { VideoResolution } from '../../shared/models/videos'
@@ -11,18 +11,25 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' 11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
12import { CONFIG } from '../initializers/config' 12import { CONFIG } from '../initializers/config'
13 13
14/**
15 * Optimize the original video file and replace it. The resolution is not changed.
16 */
14async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { 17async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) {
15 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 18 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
19 const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
16 const newExtname = '.mp4' 20 const newExtname = '.mp4'
17 21
18 const inputVideoFile = inputVideoFileArg ? inputVideoFileArg : video.getOriginalFile() 22 const inputVideoFile = inputVideoFileArg ? inputVideoFileArg : video.getOriginalFile()
19 const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) 23 const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile))
20 const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) 24 const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname)
25
26 const doQuickTranscode = await(canDoQuickTranscode(videoInputPath))
21 27
22 const transcodeOptions = { 28 const transcodeOptions = {
23 inputPath: videoInputPath, 29 inputPath: videoInputPath,
24 outputPath: videoTranscodedPath, 30 outputPath: videoTranscodedPath,
25 resolution: inputVideoFile.resolution 31 resolution: inputVideoFile.resolution,
32 doQuickTranscode
26 } 33 }
27 34
28 // Could be very long! 35 // Could be very long!
@@ -34,10 +41,11 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi
34 // Important to do this before getVideoFilename() to take in account the new file extension 41 // Important to do this before getVideoFilename() to take in account the new file extension
35 inputVideoFile.set('extname', newExtname) 42 inputVideoFile.set('extname', newExtname)
36 43
44 const stats = await stat(videoTranscodedPath)
45 const fps = await getVideoFileFPS(videoTranscodedPath)
46
37 const videoOutputPath = video.getVideoFilePath(inputVideoFile) 47 const videoOutputPath = video.getVideoFilePath(inputVideoFile)
38 await move(videoTranscodedPath, videoOutputPath) 48 await move(videoTranscodedPath, videoOutputPath)
39 const stats = await stat(videoOutputPath)
40 const fps = await getVideoFileFPS(videoOutputPath)
41 49
42 inputVideoFile.set('size', stats.size) 50 inputVideoFile.set('size', stats.size)
43 inputVideoFile.set('fps', fps) 51 inputVideoFile.set('fps', fps)
@@ -52,8 +60,12 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi
52 } 60 }
53} 61}
54 62
63/**
64 * Transcode the original video file to a lower resolution.
65 */
55async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { 66async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) {
56 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 67 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
68 const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
57 const extname = '.mp4' 69 const extname = '.mp4'
58 70
59 // We are sure it's x264 in mp4 because optimizeOriginalVideofile was already executed 71 // We are sure it's x264 in mp4 because optimizeOriginalVideofile was already executed
@@ -66,18 +78,21 @@ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoR
66 videoId: video.id 78 videoId: video.id
67 }) 79 })
68 const videoOutputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(newVideoFile)) 80 const videoOutputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(newVideoFile))
81 const videoTranscodedPath = join(transcodeDirectory, video.getVideoFilename(newVideoFile))
69 82
70 const transcodeOptions = { 83 const transcodeOptions = {
71 inputPath: videoInputPath, 84 inputPath: videoInputPath,
72 outputPath: videoOutputPath, 85 outputPath: videoTranscodedPath,
73 resolution, 86 resolution,
74 isPortraitMode: isPortrait 87 isPortraitMode: isPortrait
75 } 88 }
76 89
77 await transcode(transcodeOptions) 90 await transcode(transcodeOptions)
78 91
79 const stats = await stat(videoOutputPath) 92 const stats = await stat(videoTranscodedPath)
80 const fps = await getVideoFileFPS(videoOutputPath) 93 const fps = await getVideoFileFPS(videoTranscodedPath)
94
95 await move(videoTranscodedPath, videoOutputPath)
81 96
82 newVideoFile.set('size', stats.size) 97 newVideoFile.set('size', stats.size)
83 newVideoFile.set('fps', fps) 98 newVideoFile.set('fps', fps)