Skip to content

Commit 2471715

Browse files
committed
Rebuild thumbnail and media file architecture
* Move to sharp library to improve image manipulation performance and support more image formats * Move video previews in thumbnails directory * Deprecate lazy static previews endpoint * Plugin `getFiles()` API now includes a `width`/`height` attribute * Deprecate previewfile for video publication/update. Use `thumbnailfile` instead * Deprecate `thumbnailPath` and `previewPath` of `Video` in favour of `thumbnails` * Deprecate `thumbnailPath` of `VideoPlaylist` in favour of `thumbnails` * Replace `torrentPath` by `torrentFilename` and `torrentStream` for remote torrents for `filter:api.download.torrent.allowed.result` plugin filter * Remove useless `fileUrl` from `UserExport` and `VideoSource` * Remove remote captions where we don't have a valid URL * cache directory is not deleted on each run anymore * Add permanent cache for video captions and storyboards
1 parent 7aac244 commit 2471715

File tree

234 files changed

+2568
-3291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+2568
-3291
lines changed

apps/peertube-cli/src/peertube-upload.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ type UploadOptions = {
1111
username?: string
1212
password?: string
1313
thumbnail?: string
14-
preview?: string
1514
file?: string
1615
videoName?: string
1716
category?: number
@@ -38,7 +37,6 @@ export function defineUploadProgram () {
3837
.option('-U, --username <username>', 'Username')
3938
.option('-p, --password <token>', 'Password')
4039
.option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path')
41-
.option('--preview <previewPath>', 'Preview path')
4240
.option('-f, --file <file>', 'Video absolute file path')
4341
.option('-n, --video-name <name>', 'Video name')
4442
.option('-c, --category <category_number>', 'Category number', parseInt)
@@ -105,8 +103,7 @@ async function run (options: UploadOptions) {
105103
...baseAttributes,
106104

107105
fixture: options.file,
108-
thumbnailfile: options.thumbnail,
109-
previewfile: options.preview
106+
thumbnailfile: options.thumbnail
110107
}
111108

112109
try {

apps/peertube-runner/src/server/process/shared/process-vod.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export async function processAudioMergeTranscoding (options: ProcessOptions<Runn
169169

170170
let ffmpegProgress: number
171171
let audioPath: string
172-
let previewPath: string
172+
let thumbnailPath: string
173173

174174
const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `output-${buildUUID()}.mp4`)
175175

@@ -187,7 +187,7 @@ export async function processAudioMergeTranscoding (options: ProcessOptions<Runn
187187
)
188188

189189
audioPath = await downloadInputFile({ url: payload.input.audioFileUrl, runnerToken, job })
190-
previewPath = await downloadInputFile({ url: payload.input.previewFileUrl, runnerToken, job })
190+
thumbnailPath = await downloadInputFile({ url: payload.input.previewFileUrl, runnerToken, job })
191191

192192
logger.info(
193193
`Downloaded input files ${payload.input.audioFileUrl} and ${payload.input.previewFileUrl} ` +
@@ -204,7 +204,7 @@ export async function processAudioMergeTranscoding (options: ProcessOptions<Runn
204204
type: 'merge-audio',
205205

206206
audioPath,
207-
videoInputPath: previewPath,
207+
videoInputPath: thumbnailPath,
208208

209209
outputPath,
210210

@@ -227,7 +227,7 @@ export async function processAudioMergeTranscoding (options: ProcessOptions<Runn
227227
})
228228
} finally {
229229
if (audioPath) await remove(audioPath)
230-
if (previewPath) await remove(previewPath)
230+
if (thumbnailPath) await remove(thumbnailPath)
231231
if (outputPath) await remove(outputPath)
232232
if (updateProgressInterval) clearInterval(updateProgressInterval)
233233
}

client/src/app/+about/about-follows/follower-image.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit, inject } from '@angular/core'
22
import { ServerService } from '@app/core'
3-
import { Actor } from '@app/shared/shared-main/account/actor.model'
3+
import { findAppropriateImageFileUrl } from '@root-helpers/images'
44

55
@Component({
66
selector: 'my-follower-image',
@@ -15,6 +15,6 @@ export class FollowerImageComponent implements OnInit {
1515
avatarUrl: string
1616

1717
ngOnInit () {
18-
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.server.getHTMLConfig().instance, 30)
18+
this.avatarUrl = findAppropriateImageFileUrl(this.server.getHTMLConfig().instance.avatars, 30)
1919
}
2020
}

client/src/app/+about/about-follows/subscription-image.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit, inject } from '@angular/core'
22
import { ServerService } from '@app/core'
3-
import { Actor } from '@app/shared/shared-main/account/actor.model'
3+
import { findAppropriateImageFileUrl } from '@root-helpers/images'
44

55
@Component({
66
selector: 'my-subscription-image',
@@ -15,6 +15,6 @@ export class SubscriptionImageComponent implements OnInit {
1515
avatarUrl: string
1616

1717
ngOnInit () {
18-
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.server.getHTMLConfig().instance, 30)
18+
this.avatarUrl = findAppropriateImageFileUrl(this.server.getHTMLConfig().instance.avatars, 30)
1919
}
2020
}

client/src/app/+about/about.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { Component, OnInit, inject, viewChild } from '@angular/core'
22
import { RouterOutlet } from '@angular/router'
33
import { ServerService } from '@app/core'
44
import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
5-
import { Actor } from '@app/shared/shared-main/account/actor.model'
65
import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'
76
import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component'
87
import { SupportModalComponent } from '@app/shared/shared-support-modal/support-modal.component'
98
import { maxBy } from '@peertube/peertube-core-utils'
109
import { HTMLServerConfig } from '@peertube/peertube-models'
10+
import { findAppropriateImageFileUrl } from '@root-helpers/images'
1111

1212
@Component({
1313
selector: 'my-about',
@@ -34,7 +34,7 @@ export class AboutComponent implements OnInit {
3434
? maxBy(this.config.instance.banners, 'width').fileUrl
3535
: undefined
3636

37-
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.config.instance, 110)
37+
this.avatarUrl = findAppropriateImageFileUrl(this.config.instance.avatars, 110)
3838

3939
this.menuEntries = [
4040
{

client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ my-select-options {
2121
}
2222

2323
my-image-input {
24+
// Keep it sync with image size requested by the component
2425
width: 223px;
2526
height: 122px;
2627
}

client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemen
150150
videoChannelId: this.videoPlaylistToUpdate.videoChannel ? this.videoPlaylistToUpdate.videoChannel.id : null
151151
})
152152

153-
fetch(this.videoPlaylistToUpdate.thumbnailUrl)
153+
// Keep it sync with image size set in the SASS file
154+
fetch(this.videoPlaylistToUpdate.getThumbnailUrl(223))
154155
.then(response => response.blob())
155156
.then(data => {
156157
this.form.patchValue({

client/src/app/+my-library/my-video-playlists/my-video-playlists.component.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222

2323
my-video-playlist-miniature {
2424
display: block;
25+
26+
// Sync wid
2527
width: 130px;
2628
}

client/src/app/+video-watch/shared/recommendations/recommended-videos.component.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ my-video-miniature {
4949
}
5050

5151
.other-videos:not(.display-as-row) my-video-miniature {
52-
min-width: $video-thumbnail-medium-width;
53-
max-width: $video-thumbnail-medium-width;
52+
--co-miniature-max-width: #{$video-thumbnail-medium-width};
53+
54+
min-width: var(--co-miniature-min-width);
55+
max-width: var(--co-miniature-max-width);
5456
}
5557

5658
.display-as-row {

client/src/app/+video-watch/video-watch.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
870870
!video.canBypassPassword(this.authUser),
871871
videoPassword: () => videoPassword,
872872

873-
poster: video.isNSFWBlurForUser(loggedInOrAnonymousUser, this.serverConfig)
873+
thumbnails: video.isNSFWBlurForUser(loggedInOrAnonymousUser, this.serverConfig)
874874
? null
875-
: video.previewUrl,
875+
: video.thumbnails,
876876

877877
nsfwWarning: video.isNSFWHiddenOrWarned(loggedInOrAnonymousUser, this.serverConfig)
878878
? {
@@ -980,7 +980,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
980980
this.peertubePlayer.disable()
981981

982982
if (hasPlayed || !this.video.isNSFWBlurForUser(this.authUser || this.anonymousUser, this.serverConfig)) {
983-
this.peertubePlayer.setPoster(this.video.previewPath)
983+
this.peertubePlayer.setPoster(this.video.thumbnails)
984984
}
985985
}
986986

0 commit comments

Comments
 (0)