aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+videos/+video-watch/shared/information/video-alert.component.html4
-rw-r--r--client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts4
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.ts4
-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
-rw-r--r--server/tests/cli/create-import-video-file-job.ts6
-rw-r--r--support/doc/tools.md3
8 files changed, 24 insertions, 26 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html
index 33b5a47a0..6e5d0bcad 100644
--- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html
+++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html
@@ -1,3 +1,7 @@
1<div i18n class="alert alert-warning" *ngIf="isVideoTranscodingFailed()">
2 Transcoding failed, this video may not work properly.
3</div>
4
1<div i18n class="alert alert-warning" *ngIf="isVideoToImport()"> 5<div i18n class="alert alert-warning" *ngIf="isVideoToImport()">
2 The video is being imported, it will be available when the import is finished. 6 The video is being imported, it will be available when the import is finished.
3</div> 7</div>
diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts
index 257d463b4..addea53c0 100644
--- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts
@@ -14,6 +14,10 @@ export class VideoAlertComponent {
14 return this.video && this.video.state.id === VideoState.TO_TRANSCODE 14 return this.video && this.video.state.id === VideoState.TO_TRANSCODE
15 } 15 }
16 16
17 isVideoTranscodingFailed () {
18 return this.video && this.video.state.id === VideoState.TRANSCODING_FAILED
19 }
20
17 isVideoToImport () { 21 isVideoToImport () {
18 return this.video && this.video.state.id === VideoState.TO_IMPORT 22 return this.video && this.video.state.id === VideoState.TO_IMPORT
19 } 23 }
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index 37ff224ab..f387c38c2 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -175,6 +175,10 @@ export class VideoMiniatureComponent implements OnInit {
175 return $localize`Publication scheduled on ` + updateAt 175 return $localize`Publication scheduled on ` + updateAt
176 } 176 }
177 177
178 if (video.state.id === VideoState.TRANSCODING_FAILED) {
179 return $localize`Transcoding failed`
180 }
181
178 if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) { 182 if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) {
179 return $localize`Waiting transcoding` 183 return $localize`Waiting transcoding`
180 } 184 }
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
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 01817216e..1e278bacc 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -14,7 +14,7 @@ import {
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 waitJobs 15 waitJobs
16} from '@shared/extra-utils' 16} from '@shared/extra-utils'
17import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models' 17import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
18 18
19const expect = chai.expect 19const expect = chai.expect
20 20
@@ -100,7 +100,7 @@ function runTests (objectStorage: boolean) {
100 await waitJobs(servers) 100 await waitJobs(servers)
101 101
102 for (const server of servers) { 102 for (const server of servers) {
103 const { data: videos } = await server.videos.list() 103 const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
104 expect(videos).to.have.lengthOf(2) 104 expect(videos).to.have.lengthOf(2)
105 105
106 const video = videos.find(({ uuid }) => uuid === video2UUID) 106 const video = videos.find(({ uuid }) => uuid === video2UUID)
@@ -124,7 +124,7 @@ function runTests (objectStorage: boolean) {
124 await waitJobs(servers) 124 await waitJobs(servers)
125 125
126 for (const server of servers) { 126 for (const server of servers) {
127 const { data: videos } = await server.videos.list() 127 const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
128 expect(videos).to.have.lengthOf(2) 128 expect(videos).to.have.lengthOf(2)
129 129
130 const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId) 130 const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId)
diff --git a/support/doc/tools.md b/support/doc/tools.md
index 526cc98b1..c08747cdc 100644
--- a/support/doc/tools.md
+++ b/support/doc/tools.md
@@ -292,7 +292,8 @@ $ docker-compose exec -u peertube peertube npm run create-transcoding-job -- --g
292 292
293### create-import-video-file-job.js 293### create-import-video-file-job.js
294 294
295You can use this script to import a video file to replace an already uploaded file or to add a new resolution to a video. PeerTube needs to be running. 295You can use this script to import a video file to replace an already uploaded file or to add a new webtorrent resolution to a video. PeerTube needs to be running.
296You can then create a transcoding job using `npm run create-transcoding-job` if you need to optimize your file or create an HLS version of it.
296 297
297```bash 298```bash
298$ # Basic installation 299$ # Basic installation