Prefer web videos in favour of webtorrent

This commit is contained in:
Chocobozzz
2023-07-11 09:21:13 +02:00
parent c3030e944a
commit 784e2ad5c3
102 changed files with 579 additions and 570 deletions

View File

@@ -31,8 +31,8 @@ describe('Private videos all workflow', () => {
return loginPage.loginOnPeerTube2()
})
it('Should play an internal webtorrent video', async () => {
await go(FIXTURE_URLS.INTERNAL_WEBTORRENT_VIDEO)
it('Should play an internal web video video', async () => {
await go(FIXTURE_URLS.INTERNAL_WEB_VIDEO)
await videoWatchPage.waitWatchVideoName(internalVideoName)
await checkCorrectlyPlay(playerPage)
@@ -52,8 +52,8 @@ describe('Private videos all workflow', () => {
await checkCorrectlyPlay(playerPage)
})
it('Should play an internal WebTorrent video in embed', async () => {
await go(FIXTURE_URLS.INTERNAL_EMBED_WEBTORRENT_VIDEO)
it('Should play an internal Web Video in embed', async () => {
await go(FIXTURE_URLS.INTERNAL_EMBED_WEB_VIDEO)
await videoWatchPage.waitEmbedForDisplayed()
await checkCorrectlyPlay(playerPage)

View File

@@ -89,7 +89,7 @@ describe('Videos all workflow', () => {
let videoNameToExcept = videoName
if (isMobileDevice() || isSafari()) {
await go(FIXTURE_URLS.WEBTORRENT_VIDEO)
await go(FIXTURE_URLS.WEB_VIDEO)
videoNameToExcept = 'E2E tests'
} else {
await videoListPage.clickOnVideo(videoName)
@@ -176,7 +176,7 @@ describe('Videos all workflow', () => {
await videoWatchPage.waitUntilVideoName(video2Name, 40 * 1000)
})
it('Should watch the webtorrent playlist in the embed', async () => {
it('Should watch the WEB VIDEO playlist in the embed', async () => {
if (isUploadUnsupported()) return
const accessToken = await browser.execute(`return window.localStorage.getItem('access_token');`)

View File

@@ -1,14 +1,14 @@
const FIXTURE_URLS = {
INTERNAL_WEBTORRENT_VIDEO: 'https://peertube2.cpy.re/w/pwfz7NizSdPD4mJcbbmNwa?mode=webtorrent&start=0',
INTERNAL_WEB_VIDEO: 'https://peertube2.cpy.re/w/pwfz7NizSdPD4mJcbbmNwa?mode=web-video&start=0',
INTERNAL_HLS_VIDEO: 'https://peertube2.cpy.re/w/pwfz7NizSdPD4mJcbbmNwa?start=0',
INTERNAL_EMBED_WEBTORRENT_VIDEO: 'https://peertube2.cpy.re/videos/embed/pwfz7NizSdPD4mJcbbmNwa?mode=webtorrent&start=0',
INTERNAL_EMBED_WEB_VIDEO: 'https://peertube2.cpy.re/videos/embed/pwfz7NizSdPD4mJcbbmNwa?mode=web-video&start=0',
INTERNAL_EMBED_HLS_VIDEO: 'https://peertube2.cpy.re/videos/embed/pwfz7NizSdPD4mJcbbmNwa?start=0',
INTERNAL_HLS_ONLY_VIDEO: 'https://peertube2.cpy.re/w/tKQmHcqdYZRdCszLUiWM3V?start=0',
INTERNAL_EMBED_HLS_ONLY_VIDEO: 'https://peertube2.cpy.re/videos/embed/tKQmHcqdYZRdCszLUiWM3V?start=0',
WEBTORRENT_VIDEO: 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
WEB_VIDEO: 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
HLS_EMBED: 'https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50',
HLS_PLAYLIST_EMBED: 'https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a',

View File

@@ -24,19 +24,19 @@ module.exports = {
specFileRetries: 0,
capabilities: [
{
'browserName': 'chrome',
'acceptInsecureCerts': true,
'goog:chromeOptions': {
args: [ '--disable-gpu', windowSizeArg ],
prefs
}
},
// {
// 'browserName': 'chrome',
// 'acceptInsecureCerts': true,
// 'goog:chromeOptions': {
// args: [ '--disable-gpu', windowSizeArg ],
// prefs
// }
// },
{
'browserName': 'firefox',
'moz:firefoxOptions': {
binary: '/usr/bin/firefox-developer-edition',
args: [ '--headless', windowSizeArg ],
// args: [ '--headless', windowSizeArg ],
prefs
}

View File

@@ -71,7 +71,7 @@
<div class="form-group" [ngClass]="getTranscodingDisabledClass()">
<my-peertube-checkbox
inputName="transcodingWebTorrentEnabled" formControlName="enabled"
i18n-labelText labelText="WebTorrent enabled"
i18n-labelText labelText="Web Videos enabled"
>
<ng-template ptTemplate="help">
<ng-container>
@@ -93,14 +93,14 @@
<ng-container i18n>
<strong>Requires ffmpeg >= 4.1</strong>
<p>Generate HLS playlists and fragmented MP4 files resulting in a better playback than with plain WebTorrent:</p>
<p>Generate HLS playlists and fragmented MP4 files resulting in a better playback than with Web Videos:</p>
<ul>
<li>Resolution change is smoother</li>
<li>Faster playback especially with long videos</li>
<li>More stable playback (less bugs/infinite loading)</li>
</ul>
<p>If you also enabled WebTorrent support, it will multiply videos storage by 2</p>
<p>If you also enabled Web Videos support, it will multiply videos storage by 2</p>
</ng-container>
</ng-template>
</my-peertube-checkbox>

View File

@@ -59,12 +59,12 @@ export class VideoAdminService {
title: $localize`Video files`,
children: [
{
value: 'webtorrent:true isLocal:true',
label: $localize`With WebTorrent`
value: 'webVideos:true isLocal:true',
label: $localize`With Web Videos`
},
{
value: 'webtorrent:false isLocal:true',
label: $localize`Without WebTorrent`
value: 'webVideos:false isLocal:true',
label: $localize`Without Web Videos`
},
{
value: 'hls:true isLocal:true',
@@ -126,8 +126,8 @@ export class VideoAdminService {
prefix: 'hls:',
isBoolean: true
},
hasWebtorrentFiles: {
prefix: 'webtorrent:',
hasWebVideoFiles: {
prefix: 'webVideos:',
isBoolean: true
},
isLive: {

View File

@@ -83,8 +83,8 @@
</td>
<td>
<span *ngIf="isHLS(video)" class="pt-badge badge-blue">HLS</span>
<span *ngIf="isWebTorrent(video)" class="pt-badge badge-blue">WebTorrent ({{ video.files.length }})</span>
<span *ngIf="hasHLS(video)" class="pt-badge badge-blue">HLS</span>
<span *ngIf="hasWebVideos(video)" class="pt-badge badge-blue">Web Videos ({{ video.files.length }})</span>
<span i18n *ngIf="video.isLive" class="pt-badge badge-blue">Live</span>
<span i18n *ngIf="hasObjectStorage(video)" class="pt-badge badge-purple">Object storage</span>
@@ -102,8 +102,8 @@
<tr>
<td class="video-info expand-cell" myAutoColspan>
<div>
<div *ngIf="isWebTorrent(video)">
WebTorrent:
<div *ngIf="hasWebVideos(video)">
Web Videos:
<ul>
<li *ngFor="let file of video.files">
@@ -112,13 +112,13 @@
<my-global-icon
*ngIf="canRemoveOneFile(video)"
i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
(click)="removeVideoFile(video, file, 'webtorrent')"
(click)="removeVideoFile(video, file, 'web-videos')"
></my-global-icon>
</li>
</ul>
</div>
<div *ngIf="isHLS(video)">
<div *ngIf="hasHLS(video)">
HLS:
<ul>

View File

@@ -99,8 +99,8 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
iconName: 'cog'
},
{
label: $localize`Run WebTorrent transcoding`,
handler: videos => this.runTranscoding(videos, 'webtorrent'),
label: $localize`Run Web Video transcoding`,
handler: videos => this.runTranscoding(videos, 'web-video'),
isDisplayed: videos => videos.every(v => v.canRunTranscoding(this.authUser)),
iconName: 'cog'
},
@@ -111,8 +111,8 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
iconName: 'delete'
},
{
label: $localize`Delete WebTorrent files`,
handler: videos => this.removeVideoFiles(videos, 'webtorrent'),
label: $localize`Delete Web Video files`,
handler: videos => this.removeVideoFiles(videos, 'web-videos'),
isDisplayed: videos => videos.every(v => v.canRemoveFiles(this.authUser)),
iconName: 'delete'
}
@@ -150,14 +150,14 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
return video.state.id === VideoState.TO_IMPORT
}
isHLS (video: Video) {
hasHLS (video: Video) {
const p = video.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
if (!p) return false
return p.files.length !== 0
}
isWebTorrent (video: Video) {
hasWebVideos (video: Video) {
return video.files.length !== 0
}
@@ -176,14 +176,14 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
getFilesSize (video: Video) {
let files = video.files
if (this.isHLS(video)) {
if (this.hasHLS(video)) {
files = files.concat(video.streamingPlaylists[0].files)
}
return files.reduce((p, f) => p += f.size, 0)
}
async removeVideoFile (video: Video, file: VideoFile, type: 'hls' | 'webtorrent') {
async removeVideoFile (video: Video, file: VideoFile, type: 'hls' | 'web-videos') {
const message = $localize`Are you sure you want to delete this ${file.resolution.label} file?`
const res = await this.confirmService.confirm(message, $localize`Delete file`)
if (res === false) return
@@ -262,7 +262,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
})
}
private async removeVideoFiles (videos: Video[], type: 'hls' | 'webtorrent') {
private async removeVideoFiles (videos: Video[], type: 'hls' | 'web-videos') {
let message: string
if (type === 'hls') {
@@ -274,7 +274,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
} else {
// eslint-disable-next-line max-len
message = formatICU(
$localize`Are you sure you want to delete WebTorrent files of {count, plural, =1 {1 video} other {{count} videos}}?`,
$localize`Are you sure you want to delete Web Video files of {count, plural, =1 {1 video} other {{count} videos}}?`,
{ count: videos.length }
)
}
@@ -293,7 +293,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
})
}
private runTranscoding (videos: Video[], type: 'hls' | 'webtorrent') {
private runTranscoding (videos: Video[], type: 'hls' | 'web-video') {
this.videoService.runTranscoding(videos.map(v => v.id), type)
.subscribe({
next: () => {

View File

@@ -30,8 +30,6 @@ export class User implements UserServerModel {
autoPlayNextVideoPlaylist: boolean
p2pEnabled: boolean
// FIXME: deprecated in 4.1
webTorrentEnabled: never
videosHistoryEnabled: boolean
videoLanguages: string[]

View File

@@ -252,7 +252,7 @@ export class Video implements VideoServerModel {
user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
this.state.id !== VideoState.TO_TRANSCODE &&
this.hasHLS() &&
this.hasWebTorrent()
this.hasWebVideos()
}
canRunTranscoding (user: AuthUser) {
@@ -265,7 +265,7 @@ export class Video implements VideoServerModel {
return this.streamingPlaylists?.some(p => p.type === VideoStreamingPlaylistType.HLS)
}
hasWebTorrent () {
hasWebVideos () {
return this.files && this.files.length !== 0
}

View File

@@ -311,7 +311,7 @@ export class VideoService {
)
}
removeVideoFiles (videoIds: (number | string)[], type: 'hls' | 'webtorrent') {
removeVideoFiles (videoIds: (number | string)[], type: 'hls' | 'web-videos') {
return from(videoIds)
.pipe(
concatMap(id => this.authHttp.delete(VideoService.BASE_VIDEO_URL + '/' + id + '/' + type)),
@@ -320,12 +320,12 @@ export class VideoService {
)
}
removeFile (videoId: number | string, fileId: number, type: 'hls' | 'webtorrent') {
removeFile (videoId: number | string, fileId: number, type: 'hls' | 'web-videos') {
return this.authHttp.delete(VideoService.BASE_VIDEO_URL + '/' + videoId + '/' + type + '/' + fileId)
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
runTranscoding (videoIds: (number | string)[], type: 'hls' | 'webtorrent') {
runTranscoding (videoIds: (number | string)[], type: 'hls' | 'web-video') {
const body: VideoTranscodingCreate = { transcodingType: type }
return from(videoIds)

View File

@@ -273,7 +273,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
})
}
async removeVideoFiles (video: Video, type: 'hls' | 'webtorrent') {
async removeVideoFiles (video: Video, type: 'hls' | 'web-videos') {
const confirmMessage = $localize`Do you really want to remove "${this.video.name}" files?`
const res = await this.confirmService.confirm(confirmMessage, $localize`Remove "${this.video.name}" files`)
@@ -290,7 +290,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
})
}
runTranscoding (video: Video, type: 'hls' | 'webtorrent') {
runTranscoding (video: Video, type: 'hls' | 'web-video') {
this.videoService.runTranscoding([ video.id ], type)
.subscribe({
next: () => {
@@ -394,8 +394,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
iconName: 'cog'
},
{
label: $localize`Run WebTorrent transcoding`,
handler: ({ video }) => this.runTranscoding(video, 'webtorrent'),
label: $localize`Run Web Video transcoding`,
handler: ({ video }) => this.runTranscoding(video, 'web-video'),
isDisplayed: () => this.displayOptions.transcoding && this.canRunTranscoding(),
iconName: 'cog'
},
@@ -406,8 +406,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
iconName: 'delete'
},
{
label: $localize`Delete WebTorrent files`,
handler: ({ video }) => this.removeVideoFiles(video, 'webtorrent'),
label: $localize`Delete Web Video files`,
handler: ({ video }) => this.removeVideoFiles(video, 'web-videos'),
isDisplayed: () => this.displayOptions.removeFiles && this.canRemoveVideoFiles(),
iconName: 'delete'
}