aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-09 11:52:41 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-11-09 15:00:21 +0100
commit221ee1adc916684d4881d2a9c4c01954dcde986e (patch)
treef456a3f3e1fcc2d8dbd3cc6f0d72a4cb2cbbadc2 /server/lib
parent4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a (diff)
downloadPeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.tar.gz
PeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.tar.zst
PeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.zip
Add transcoding fail message in client
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts14
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts7
-rw-r--r--server/lib/video-state.ts8
3 files changed, 7 insertions, 22 deletions
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index e6c918e6c..47ae10a66 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -7,14 +7,12 @@ import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
7import { generateWebTorrentVideoFilename } from '@server/lib/paths' 7import { generateWebTorrentVideoFilename } from '@server/lib/paths'
8import { addMoveToObjectStorageJob } from '@server/lib/video' 8import { addMoveToObjectStorageJob } from '@server/lib/video'
9import { VideoPathManager } from '@server/lib/video-path-manager' 9import { VideoPathManager } from '@server/lib/video-path-manager'
10import { UserModel } from '@server/models/user/user'
11import { MVideoFullLight } from '@server/types/models' 10import { MVideoFullLight } from '@server/types/models'
12import { VideoFileImportPayload, VideoStorage } from '@shared/models' 11import { VideoFileImportPayload, VideoStorage } from '@shared/models'
13import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' 12import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
14import { logger } from '../../../helpers/logger' 13import { logger } from '../../../helpers/logger'
15import { VideoModel } from '../../../models/video/video' 14import { VideoModel } from '../../../models/video/video'
16import { VideoFileModel } from '../../../models/video/video-file' 15import { VideoFileModel } from '../../../models/video/video-file'
17import { createHlsJobIfEnabled } from './video-transcoding'
18 16
19async function processVideoFileImport (job: Job) { 17async function processVideoFileImport (job: Job) {
20 const payload = job.data as VideoFileImportPayload 18 const payload = job.data as VideoFileImportPayload
@@ -27,20 +25,8 @@ async function processVideoFileImport (job: Job) {
27 return undefined 25 return undefined
28 } 26 }
29 27
30 const data = await getVideoFileResolution(payload.filePath)
31
32 await updateVideoFile(video, payload.filePath) 28 await updateVideoFile(video, payload.filePath)
33 29
34 const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId)
35
36 await createHlsJobIfEnabled(user, {
37 videoUUID: video.uuid,
38 resolution: data.resolution,
39 isPortraitMode: data.isPortraitMode,
40 copyCodecs: true,
41 isMaxQuality: false
42 })
43
44 if (CONFIG.OBJECT_STORAGE.ENABLED) { 30 if (CONFIG.OBJECT_STORAGE.ENABLED) {
45 await addMoveToObjectStorageJob(video) 31 await addMoveToObjectStorageJob(video)
46 } else { 32 } else {
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index b280a1cc9..0143cd02a 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -2,7 +2,7 @@ import { Job } from 'bull'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 4import { VideoPathManager } from '@server/lib/video-path-manager'
5import { moveToFailedState, moveToNextState } from '@server/lib/video-state' 5import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state'
6import { UserModel } from '@server/models/user/user' 6import { UserModel } from '@server/models/user/user'
7import { VideoJobInfoModel } from '@server/models/video/video-job-info' 7import { VideoJobInfoModel } from '@server/models/video/video-job-info'
8import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' 8import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models'
@@ -52,14 +52,15 @@ async function processVideoTranscoding (job: Job) {
52 const handler = handlers[payload.type] 52 const handler = handlers[payload.type]
53 53
54 if (!handler) { 54 if (!handler) {
55 await moveToFailedState(video) 55 await moveToFailedTranscodingState(video)
56
56 throw new Error('Cannot find transcoding handler for ' + payload.type) 57 throw new Error('Cannot find transcoding handler for ' + payload.type)
57 } 58 }
58 59
59 try { 60 try {
60 await handler(job, payload, video, user) 61 await handler(job, payload, video, user)
61 } catch (error) { 62 } catch (error) {
62 await moveToFailedState(video) 63 await moveToFailedTranscodingState(video)
63 64
64 throw error 65 throw error
65 } 66 }
diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts
index 2260e90f5..0b51f5c6b 100644
--- a/server/lib/video-state.ts
+++ b/server/lib/video-state.ts
@@ -79,10 +79,8 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b
79 } 79 }
80} 80}
81 81
82function moveToFailedState (video: MVideoFullLight) { 82function moveToFailedTranscodingState (video: MVideoFullLight) {
83 return sequelizeTypescript.transaction(async t => { 83 return video.setNewState(VideoState.TRANSCODING_FAILED, false, undefined)
84 await video.setNewState(VideoState.TRANSCODING_FAILED, false, t)
85 })
86} 84}
87 85
88// --------------------------------------------------------------------------- 86// ---------------------------------------------------------------------------
@@ -90,7 +88,7 @@ function moveToFailedState (video: MVideoFullLight) {
90export { 88export {
91 buildNextVideoState, 89 buildNextVideoState,
92 moveToExternalStorageState, 90 moveToExternalStorageState,
93 moveToFailedState, 91 moveToFailedTranscodingState,
94 moveToNextState 92 moveToNextState
95} 93}
96 94