diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-15 15:56:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 15:56:56 +0100 |
commit | 454c20fa7cdb05eba7f1be3c83389b54807af0b3 (patch) | |
tree | e9b364da69eaf88f0470414c506c3b5631984c60 /server/tests | |
parent | d43c6b1ffc5e6c895f9e9f9de6625f17a9755c20 (diff) | |
download | PeerTube-454c20fa7cdb05eba7f1be3c83389b54807af0b3.tar.gz PeerTube-454c20fa7cdb05eba7f1be3c83389b54807af0b3.tar.zst PeerTube-454c20fa7cdb05eba7f1be3c83389b54807af0b3.zip |
stricter youtubedl format selectors (#3516)
* stricter youtubedl format selectors
make sure selectors avoid av1, and otherwise match as closely to the
maximum resolution enabled for transcoding
* add support for merge formats in youtubedl
* avoid vp9.2 in youtubedl to avoid any HDR
* move getEnabledResolutions, safer replace of imported extension
* add test for youtube-dl selectors
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 75 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 36 |
2 files changed, 84 insertions, 27 deletions
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 8d19a4274..61e7a81ee 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -14,12 +14,19 @@ import { | |||
14 | listVideoCaptions, | 14 | listVideoCaptions, |
15 | ServerInfo, | 15 | ServerInfo, |
16 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
17 | testCaptionFile | 17 | testCaptionFile, |
18 | updateCustomSubConfig | ||
18 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
19 | import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs' | 20 | import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs' |
20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
21 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 22 | import { |
22 | import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' | 23 | getMagnetURI, |
24 | getMyVideoImports, | ||
25 | getYoutubeHDRVideoUrl, | ||
26 | getYoutubeVideoUrl, | ||
27 | importVideo | ||
28 | } from '../../../../shared/extra-utils/videos/video-imports' | ||
29 | import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos' | ||
23 | 30 | ||
24 | const expect = chai.expect | 31 | const expect = chai.expect |
25 | 32 | ||
@@ -90,7 +97,7 @@ describe('Test video imports', function () { | |||
90 | } | 97 | } |
91 | 98 | ||
92 | before(async function () { | 99 | before(async function () { |
93 | this.timeout(30000) | 100 | this.timeout(30_000) |
94 | 101 | ||
95 | // Run servers | 102 | // Run servers |
96 | servers = await flushAndRunMultipleServers(2) | 103 | servers = await flushAndRunMultipleServers(2) |
@@ -111,7 +118,7 @@ describe('Test video imports', function () { | |||
111 | }) | 118 | }) |
112 | 119 | ||
113 | it('Should import videos on server 1', async function () { | 120 | it('Should import videos on server 1', async function () { |
114 | this.timeout(60000) | 121 | this.timeout(60_000) |
115 | 122 | ||
116 | const baseAttributes = { | 123 | const baseAttributes = { |
117 | channelId: channelIdServer1, | 124 | channelId: channelIdServer1, |
@@ -223,7 +230,7 @@ Ajouter un sous-titre est vraiment facile`) | |||
223 | }) | 230 | }) |
224 | 231 | ||
225 | it('Should have the video listed on the two instances', async function () { | 232 | it('Should have the video listed on the two instances', async function () { |
226 | this.timeout(120000) | 233 | this.timeout(120_000) |
227 | 234 | ||
228 | await waitJobs(servers) | 235 | await waitJobs(servers) |
229 | 236 | ||
@@ -238,7 +245,7 @@ Ajouter un sous-titre est vraiment facile`) | |||
238 | }) | 245 | }) |
239 | 246 | ||
240 | it('Should import a video on server 2 with some fields', async function () { | 247 | it('Should import a video on server 2 with some fields', async function () { |
241 | this.timeout(60000) | 248 | this.timeout(60_000) |
242 | 249 | ||
243 | const attributes = { | 250 | const attributes = { |
244 | targetUrl: getYoutubeVideoUrl(), | 251 | targetUrl: getYoutubeVideoUrl(), |
@@ -256,7 +263,7 @@ Ajouter un sous-titre est vraiment facile`) | |||
256 | }) | 263 | }) |
257 | 264 | ||
258 | it('Should have the videos listed on the two instances', async function () { | 265 | it('Should have the videos listed on the two instances', async function () { |
259 | this.timeout(120000) | 266 | this.timeout(120_000) |
260 | 267 | ||
261 | await waitJobs(servers) | 268 | await waitJobs(servers) |
262 | 269 | ||
@@ -273,7 +280,7 @@ Ajouter un sous-titre est vraiment facile`) | |||
273 | }) | 280 | }) |
274 | 281 | ||
275 | it('Should import a video that will be transcoded', async function () { | 282 | it('Should import a video that will be transcoded', async function () { |
276 | this.timeout(120000) | 283 | this.timeout(120_000) |
277 | 284 | ||
278 | const attributes = { | 285 | const attributes = { |
279 | name: 'transcoded video', | 286 | name: 'transcoded video', |
@@ -295,6 +302,56 @@ Ajouter un sous-titre est vraiment facile`) | |||
295 | } | 302 | } |
296 | }) | 303 | }) |
297 | 304 | ||
305 | it('Should import no HDR version on a HDR video', async function () { | ||
306 | this.timeout(120_000) | ||
307 | |||
308 | const config = { | ||
309 | transcoding: { | ||
310 | enabled: true, | ||
311 | resolutions: { | ||
312 | '240p': false, | ||
313 | '360p': false, | ||
314 | '480p': false, | ||
315 | '720p': false, | ||
316 | '1080p': true, // the resulting resolution shouldn't be higher than this, and not vp9.2/av01 | ||
317 | '1440p': false, | ||
318 | '2160p': false | ||
319 | }, | ||
320 | webtorrent: { enabled: true }, | ||
321 | hls: { enabled: false } | ||
322 | }, | ||
323 | import: { | ||
324 | videos: { | ||
325 | http: { | ||
326 | enabled: true | ||
327 | }, | ||
328 | torrent: { | ||
329 | enabled: true | ||
330 | } | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
335 | |||
336 | const attributes = { | ||
337 | name: 'hdr video', | ||
338 | targetUrl: getYoutubeHDRVideoUrl(), | ||
339 | channelId: channelIdServer1, | ||
340 | privacy: VideoPrivacy.PUBLIC | ||
341 | } | ||
342 | const res1 = await importVideo(servers[0].url, servers[0].accessToken, attributes) | ||
343 | const videoUUID = res1.body.video.uuid | ||
344 | |||
345 | await waitJobs(servers) | ||
346 | |||
347 | // test resolution | ||
348 | const res2 = await getVideo(servers[0].url, videoUUID) | ||
349 | const video: VideoDetails = res2.body | ||
350 | expect(video.name).to.equal('hdr video') | ||
351 | const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id })) | ||
352 | expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) | ||
353 | }) | ||
354 | |||
298 | after(async function () { | 355 | after(async function () { |
299 | await cleanupTests(servers) | 356 | await cleanupTests(servers) |
300 | }) | 357 | }) |
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 817d9faf2..32f566506 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -45,7 +45,7 @@ describe('Test video transcoding', function () { | |||
45 | let servers: ServerInfo[] = [] | 45 | let servers: ServerInfo[] = [] |
46 | 46 | ||
47 | before(async function () { | 47 | before(async function () { |
48 | this.timeout(30000) | 48 | this.timeout(30_000) |
49 | 49 | ||
50 | // Run servers | 50 | // Run servers |
51 | servers = await flushAndRunMultipleServers(2) | 51 | servers = await flushAndRunMultipleServers(2) |
@@ -56,7 +56,7 @@ describe('Test video transcoding', function () { | |||
56 | }) | 56 | }) |
57 | 57 | ||
58 | it('Should not transcode video on server 1', async function () { | 58 | it('Should not transcode video on server 1', async function () { |
59 | this.timeout(60000) | 59 | this.timeout(60_000) |
60 | 60 | ||
61 | const videoAttributes = { | 61 | const videoAttributes = { |
62 | name: 'my super name for server 1', | 62 | name: 'my super name for server 1', |
@@ -86,7 +86,7 @@ describe('Test video transcoding', function () { | |||
86 | }) | 86 | }) |
87 | 87 | ||
88 | it('Should transcode video on server 2', async function () { | 88 | it('Should transcode video on server 2', async function () { |
89 | this.timeout(120000) | 89 | this.timeout(120_000) |
90 | 90 | ||
91 | const videoAttributes = { | 91 | const videoAttributes = { |
92 | name: 'my super name for server 2', | 92 | name: 'my super name for server 2', |
@@ -117,7 +117,7 @@ describe('Test video transcoding', function () { | |||
117 | }) | 117 | }) |
118 | 118 | ||
119 | it('Should transcode high bit rate mp3 to proper bit rate', async function () { | 119 | it('Should transcode high bit rate mp3 to proper bit rate', async function () { |
120 | this.timeout(60000) | 120 | this.timeout(60_000) |
121 | 121 | ||
122 | const videoAttributes = { | 122 | const videoAttributes = { |
123 | name: 'mp3_256k', | 123 | name: 'mp3_256k', |
@@ -149,7 +149,7 @@ describe('Test video transcoding', function () { | |||
149 | }) | 149 | }) |
150 | 150 | ||
151 | it('Should transcode video with no audio and have no audio itself', async function () { | 151 | it('Should transcode video with no audio and have no audio itself', async function () { |
152 | this.timeout(60000) | 152 | this.timeout(60_000) |
153 | 153 | ||
154 | const videoAttributes = { | 154 | const videoAttributes = { |
155 | name: 'no_audio', | 155 | name: 'no_audio', |
@@ -174,7 +174,7 @@ describe('Test video transcoding', function () { | |||
174 | }) | 174 | }) |
175 | 175 | ||
176 | it('Should leave the audio untouched, but properly transcode the video', async function () { | 176 | it('Should leave the audio untouched, but properly transcode the video', async function () { |
177 | this.timeout(60000) | 177 | this.timeout(60_000) |
178 | 178 | ||
179 | const videoAttributes = { | 179 | const videoAttributes = { |
180 | name: 'untouched_audio', | 180 | name: 'untouched_audio', |
@@ -209,7 +209,7 @@ describe('Test video transcoding', function () { | |||
209 | }) | 209 | }) |
210 | 210 | ||
211 | it('Should transcode a 60 FPS video', async function () { | 211 | it('Should transcode a 60 FPS video', async function () { |
212 | this.timeout(60000) | 212 | this.timeout(60_000) |
213 | 213 | ||
214 | const videoAttributes = { | 214 | const videoAttributes = { |
215 | name: 'my super 30fps name for server 2', | 215 | name: 'my super 30fps name for server 2', |
@@ -248,7 +248,7 @@ describe('Test video transcoding', function () { | |||
248 | }) | 248 | }) |
249 | 249 | ||
250 | it('Should wait for transcoding before publishing the video', async function () { | 250 | it('Should wait for transcoding before publishing the video', async function () { |
251 | this.timeout(160000) | 251 | this.timeout(160_000) |
252 | 252 | ||
253 | { | 253 | { |
254 | // Upload the video, but wait transcoding | 254 | // Upload the video, but wait transcoding |
@@ -301,7 +301,7 @@ describe('Test video transcoding', function () { | |||
301 | }) | 301 | }) |
302 | 302 | ||
303 | it('Should respect maximum bitrate values', async function () { | 303 | it('Should respect maximum bitrate values', async function () { |
304 | this.timeout(160000) | 304 | this.timeout(160_000) |
305 | 305 | ||
306 | let tempFixturePath: string | 306 | let tempFixturePath: string |
307 | 307 | ||
@@ -341,7 +341,7 @@ describe('Test video transcoding', function () { | |||
341 | }) | 341 | }) |
342 | 342 | ||
343 | it('Should accept and transcode additional extensions', async function () { | 343 | it('Should accept and transcode additional extensions', async function () { |
344 | this.timeout(300000) | 344 | this.timeout(300_000) |
345 | 345 | ||
346 | let tempFixturePath: string | 346 | let tempFixturePath: string |
347 | 347 | ||
@@ -378,14 +378,14 @@ describe('Test video transcoding', function () { | |||
378 | }) | 378 | }) |
379 | 379 | ||
380 | it('Should correctly detect if quick transcode is possible', async function () { | 380 | it('Should correctly detect if quick transcode is possible', async function () { |
381 | this.timeout(10000) | 381 | this.timeout(10_000) |
382 | 382 | ||
383 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true | 383 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true |
384 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false | 384 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false |
385 | }) | 385 | }) |
386 | 386 | ||
387 | it('Should merge an audio file with the preview file', async function () { | 387 | it('Should merge an audio file with the preview file', async function () { |
388 | this.timeout(60000) | 388 | this.timeout(60_000) |
389 | 389 | ||
390 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } | 390 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } |
391 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) | 391 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
@@ -410,7 +410,7 @@ describe('Test video transcoding', function () { | |||
410 | }) | 410 | }) |
411 | 411 | ||
412 | it('Should upload an audio file and choose a default background image', async function () { | 412 | it('Should upload an audio file and choose a default background image', async function () { |
413 | this.timeout(60000) | 413 | this.timeout(60_000) |
414 | 414 | ||
415 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } | 415 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } |
416 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) | 416 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
@@ -435,7 +435,7 @@ describe('Test video transcoding', function () { | |||
435 | }) | 435 | }) |
436 | 436 | ||
437 | it('Should downscale to the closest divisor standard framerate', async function () { | 437 | it('Should downscale to the closest divisor standard framerate', async function () { |
438 | this.timeout(200000) | 438 | this.timeout(200_000) |
439 | 439 | ||
440 | let tempFixturePath: string | 440 | let tempFixturePath: string |
441 | 441 | ||
@@ -476,7 +476,7 @@ describe('Test video transcoding', function () { | |||
476 | }) | 476 | }) |
477 | 477 | ||
478 | it('Should not transcode to an higher bitrate than the original file', async function () { | 478 | it('Should not transcode to an higher bitrate than the original file', async function () { |
479 | this.timeout(160000) | 479 | this.timeout(160_000) |
480 | 480 | ||
481 | const config = { | 481 | const config = { |
482 | transcoding: { | 482 | transcoding: { |
@@ -508,12 +508,12 @@ describe('Test video transcoding', function () { | |||
508 | 508 | ||
509 | const resolutions = [ 240, 360, 480, 720, 1080 ] | 509 | const resolutions = [ 240, 360, 480, 720, 1080 ] |
510 | for (const r of resolutions) { | 510 | for (const r of resolutions) { |
511 | expect(await getServerFileSize(servers[1], `videos/${videoUUID}-${r}.mp4`)).to.be.below(60000) | 511 | expect(await getServerFileSize(servers[1], `videos/${videoUUID}-${r}.mp4`)).to.be.below(60_000) |
512 | } | 512 | } |
513 | }) | 513 | }) |
514 | 514 | ||
515 | it('Should provide valid ffprobe data', async function () { | 515 | it('Should provide valid ffprobe data', async function () { |
516 | this.timeout(160000) | 516 | this.timeout(160_000) |
517 | 517 | ||
518 | const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid | 518 | const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid |
519 | await waitJobs(servers) | 519 | await waitJobs(servers) |
@@ -570,7 +570,7 @@ describe('Test video transcoding', function () { | |||
570 | }) | 570 | }) |
571 | 571 | ||
572 | it('Should transcode a 4k video', async function () { | 572 | it('Should transcode a 4k video', async function () { |
573 | this.timeout(200000) | 573 | this.timeout(200_000) |
574 | 574 | ||
575 | const videoAttributes = { | 575 | const videoAttributes = { |
576 | name: '4k video', | 576 | name: '4k video', |