diff options
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' | |||
7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' |
8 | import { addMoveToObjectStorageJob } from '@server/lib/video' | 8 | import { addMoveToObjectStorageJob } from '@server/lib/video' |
9 | import { VideoPathManager } from '@server/lib/video-path-manager' | 9 | import { VideoPathManager } from '@server/lib/video-path-manager' |
10 | import { UserModel } from '@server/models/user/user' | ||
11 | import { MVideoFullLight } from '@server/types/models' | 10 | import { MVideoFullLight } from '@server/types/models' |
12 | import { VideoFileImportPayload, VideoStorage } from '@shared/models' | 11 | import { VideoFileImportPayload, VideoStorage } from '@shared/models' |
13 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' | 12 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' |
14 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
15 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
16 | import { VideoFileModel } from '../../../models/video/video-file' | 15 | import { VideoFileModel } from '../../../models/video/video-file' |
17 | import { createHlsJobIfEnabled } from './video-transcoding' | ||
18 | 16 | ||
19 | async function processVideoFileImport (job: Job) { | 17 | async 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' | |||
2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' | 2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' |
3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' | 3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { VideoPathManager } from '@server/lib/video-path-manager' |
5 | import { moveToFailedState, moveToNextState } from '@server/lib/video-state' | 5 | import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state' |
6 | import { UserModel } from '@server/models/user/user' | 6 | import { UserModel } from '@server/models/user/user' |
7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | 7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' |
8 | import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' | 8 | import { 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 | ||
82 | function moveToFailedState (video: MVideoFullLight) { | 82 | function 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) { | |||
90 | export { | 88 | export { |
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' |
17 | import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models' | 17 | import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const 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 | ||
295 | You 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. | 295 | You 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. |
296 | You 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 |