Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Allow to bulk force transcoding

Chocobozzz57c94fb51cee
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 7947c8760d..30868499d0 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -351,7 +351,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
}
private runTranscoding (videos: Video[], type: 'hls' | 'web-video') {
- this.videoService.runTranscoding({ videoIds: videos.map(v => v.id), type, askForForceTranscodingIfNeeded: false })
+ this.videoService.runTranscoding({ videos, type, askForForceTranscodingIfNeeded: true })
.subscribe({
next: () => {
this.notifier.success($localize`Transcoding jobs created.`)
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 1d500e5615..7c5b2e9ca9 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -270,7 +270,7 @@ export class Video implements VideoServerModel {
}
canRunTranscoding (user: AuthUser) {
- return this.canRunForcedTranscoding(user) && this.state.id !== VideoState.TO_TRANSCODE
+ return this.canRunForcedTranscoding(user)
}
canRunForcedTranscoding (user: AuthUser) {
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index b2605d7470..33acad2cba 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -1,6 +1,3 @@
-import { SortMeta } from 'primeng/api'
-import { from, Observable, of, throwError } from 'rxjs'
-import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
@@ -16,7 +13,6 @@ import {
UserVideoRate,
UserVideoRateType,
UserVideoRateUpdate,
- Video as VideoServerModel,
VideoChannel as VideoChannelServerModel,
VideoConstant,
VideoDetails as VideoDetailsServerModel,
@@ -24,20 +20,24 @@ import {
VideoIncludeType,
VideoPrivacy,
VideoPrivacyType,
+ Video as VideoServerModel,
VideoSortField,
VideoSource,
VideoTranscodingCreate,
VideoUpdate
} from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { from, Observable, of, throwError } from 'rxjs'
+import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
import { environment } from '../../../../environments/environment'
import { Account } from '../account/account.model'
import { AccountService } from '../account/account.service'
+import { VideoChannel } from '../video-channel/video-channel.model'
+import { VideoChannelService } from '../video-channel/video-channel.service'
import { VideoDetails } from './video-details.model'
import { VideoEdit } from './video-edit.model'
import { VideoPasswordService } from './video-password.service'
import { Video } from './video.model'
-import { VideoChannel } from '../video-channel/video-channel.model'
-import { VideoChannelService } from '../video-channel/video-channel.service'
export type CommonVideoParams = {
videoPagination?: ComponentPaginationLight
@@ -332,27 +332,23 @@ export class VideoService {
}
runTranscoding (options: {
- videoIds: (number | string)[]
+ videos: Video[]
type: 'hls' | 'web-video'
askForForceTranscodingIfNeeded: boolean
forceTranscoding?: boolean
}): Observable<any> {
- const { videoIds, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
-
- if (askForForceTranscodingIfNeeded && videoIds.length !== 1) {
- throw new Error('Cannot ask to force transcoding on multiple videos')
- }
+ const { videos, type, askForForceTranscodingIfNeeded, forceTranscoding } = options
const body: VideoTranscodingCreate = { transcodingType: type, forceTranscoding }
- return from(videoIds)
+ return from(videos)
.pipe(
- concatMap(id => {
- return this.authHttp.post(VideoService.BASE_VIDEO_URL + '/' + id + '/transcoding', body)
+ concatMap(video => {
+ return this.authHttp.post(VideoService.BASE_VIDEO_URL + '/' + video.uuid + '/transcoding', body)
.pipe(
catchError(err => {
if (askForForceTranscodingIfNeeded && err.error?.code === ServerErrorCode.VIDEO_ALREADY_BEING_TRANSCODED) {
- const message = $localize`PeerTube considers this video is already being transcoded.` +
+ const message = $localize`PeerTube considers video "${video.name}" is already being transcoded.` +
// eslint-disable-next-line max-len
$localize` If you think PeerTube is wrong (video in broken state after a crash etc.), you can force transcoding on this video.` +
` Do you still want to run transcoding?`
@@ -362,7 +358,12 @@ export class VideoService {
switchMap(res => {
if (res === false) return throwError(() => err)
- return this.runTranscoding({ videoIds, type, askForForceTranscodingIfNeeded: false, forceTranscoding: true })
+ return this.runTranscoding({
+ videos: [ video ],
+ type,
+ askForForceTranscodingIfNeeded: false,
+ forceTranscoding: true
+ })
})
)
}
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
index 6633b869ee..b46a8d4acb 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
@@ -335,7 +335,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
}
runTranscoding (video: Video, type: 'hls' | 'web-video') {
- this.videoService.runTranscoding({ videoIds: [ video.id ], type, askForForceTranscodingIfNeeded: true })
+ this.videoService.runTranscoding({ videos: [ video ], type, askForForceTranscodingIfNeeded: true })
.subscribe({
next: () => {
this.notifier.success($localize`Transcoding jobs created for "${video.name}".`)