Add transcoding fail message in client

pull/4548/head
Chocobozzz 2021-11-09 11:52:41 +01:00 committed by Chocobozzz
parent 4e29f4fe23
commit 221ee1adc9
8 changed files with 24 additions and 26 deletions

View File

@ -1,3 +1,7 @@
<div i18n class="alert alert-warning" *ngIf="isVideoTranscodingFailed()">
Transcoding failed, this video may not work properly.
</div>
<div i18n class="alert alert-warning" *ngIf="isVideoToImport()">
The video is being imported, it will be available when the import is finished.
</div>

View File

@ -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
}

View File

@ -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`
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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)

View File

@ -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