From 221ee1adc916684d4881d2a9c4c01954dcde986e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Nov 2021 11:52:41 +0100 Subject: Add transcoding fail message in client --- .../shared/information/video-alert.component.html | 4 ++++ .../shared/information/video-alert.component.ts | 4 ++++ .../shared-video-miniature/video-miniature.component.ts | 4 ++++ server/lib/job-queue/handlers/video-file-import.ts | 14 -------------- server/lib/job-queue/handlers/video-transcoding.ts | 7 ++++--- server/lib/video-state.ts | 8 +++----- server/tests/cli/create-import-video-file-job.ts | 6 +++--- support/doc/tools.md | 3 ++- 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 @@ +
+ Transcoding failed, this video may not work properly. +
+
The video is being imported, it will be available when the import is finished.
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 { return this.video && this.video.state.id === VideoState.TO_TRANSCODE } + isVideoTranscodingFailed () { + return this.video && this.video.state.id === VideoState.TRANSCODING_FAILED + } + isVideoToImport () { return this.video && this.video.state.id === VideoState.TO_IMPORT } 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 { return $localize`Publication scheduled on ` + updateAt } + if (video.state.id === VideoState.TRANSCODING_FAILED) { + return $localize`Transcoding failed` + } + if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) { return $localize`Waiting transcoding` } 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' import { generateWebTorrentVideoFilename } from '@server/lib/paths' import { addMoveToObjectStorageJob } from '@server/lib/video' import { VideoPathManager } from '@server/lib/video-path-manager' -import { UserModel } from '@server/models/user/user' import { MVideoFullLight } from '@server/types/models' import { VideoFileImportPayload, VideoStorage } from '@shared/models' import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' import { logger } from '../../../helpers/logger' import { VideoModel } from '../../../models/video/video' import { VideoFileModel } from '../../../models/video/video-file' -import { createHlsJobIfEnabled } from './video-transcoding' async function processVideoFileImport (job: Job) { const payload = job.data as VideoFileImportPayload @@ -27,20 +25,8 @@ async function processVideoFileImport (job: Job) { return undefined } - const data = await getVideoFileResolution(payload.filePath) - await updateVideoFile(video, payload.filePath) - const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId) - - await createHlsJobIfEnabled(user, { - videoUUID: video.uuid, - resolution: data.resolution, - isPortraitMode: data.isPortraitMode, - copyCodecs: true, - isMaxQuality: false - }) - if (CONFIG.OBJECT_STORAGE.ENABLED) { await addMoveToObjectStorageJob(video) } 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' import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' import { VideoPathManager } from '@server/lib/video-path-manager' -import { moveToFailedState, moveToNextState } from '@server/lib/video-state' +import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state' import { UserModel } from '@server/models/user/user' import { VideoJobInfoModel } from '@server/models/video/video-job-info' import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' @@ -52,14 +52,15 @@ async function processVideoTranscoding (job: Job) { const handler = handlers[payload.type] if (!handler) { - await moveToFailedState(video) + await moveToFailedTranscodingState(video) + throw new Error('Cannot find transcoding handler for ' + payload.type) } try { await handler(job, payload, video, user) } catch (error) { - await moveToFailedState(video) + await moveToFailedTranscodingState(video) throw error } 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 } } -function moveToFailedState (video: MVideoFullLight) { - return sequelizeTypescript.transaction(async t => { - await video.setNewState(VideoState.TRANSCODING_FAILED, false, t) - }) +function moveToFailedTranscodingState (video: MVideoFullLight) { + return video.setNewState(VideoState.TRANSCODING_FAILED, false, undefined) } // --------------------------------------------------------------------------- @@ -90,7 +88,7 @@ function moveToFailedState (video: MVideoFullLight) { export { buildNextVideoState, moveToExternalStorageState, - moveToFailedState, + moveToFailedTranscodingState, moveToNextState } 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 { setAccessTokensToServers, waitJobs } from '@shared/extra-utils' -import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models' +import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' const expect = chai.expect @@ -100,7 +100,7 @@ function runTests (objectStorage: boolean) { await waitJobs(servers) for (const server of servers) { - const { data: videos } = await server.videos.list() + const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE }) expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video2UUID) @@ -124,7 +124,7 @@ function runTests (objectStorage: boolean) { await waitJobs(servers) for (const server of servers) { - const { data: videos } = await server.videos.list() + const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE }) expect(videos).to.have.lengthOf(2) 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 ### create-import-video-file-job.js -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. +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. +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. ```bash $ # Basic installation -- cgit v1.2.3