]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
0e1dc3e7 | 2 | |
0e1dc3e7 | 3 | import * as chai from 'chai' |
a7ba16b6 | 4 | import 'mocha' |
7160878c | 5 | import { omit } from 'lodash' |
c1c86c15 | 6 | import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' |
8319d6ae RK |
7 | import { |
8 | audio, | |
9 | canDoQuickTranscode, | |
10 | getVideoFileBitrate, | |
11 | getVideoFileFPS, | |
12 | getVideoFileResolution, | |
13 | getMetadataFromFile | |
14 | } from '../../../helpers/ffmpeg-utils' | |
0e1dc3e7 | 15 | import { |
7243f84d C |
16 | buildAbsoluteFixturePath, |
17 | cleanupTests, | |
2186386c C |
18 | doubleFollow, |
19 | flushAndRunMultipleServers, | |
d175a6f7 | 20 | generateHighBitrateVideo, |
837666fe | 21 | generateVideoWithFramerate, |
2186386c | 22 | getMyVideos, |
d218e7de | 23 | getServerFileSize, |
2186386c | 24 | getVideo, |
8319d6ae | 25 | getVideoFileMetadataUrl, |
2186386c | 26 | getVideosList, |
b345a804 | 27 | makeGetRequest, |
2186386c C |
28 | root, |
29 | ServerInfo, | |
30 | setAccessTokensToServers, | |
d218e7de | 31 | updateCustomSubConfig, |
7b81edc8 | 32 | uploadVideo, uploadVideoAndGetId, |
1600235a | 33 | waitJobs, |
d175a6f7 | 34 | webtorrentAdd |
94565d52 | 35 | } from '../../../../shared/extra-utils' |
7243f84d | 36 | import { join } from 'path' |
edb4ffc7 | 37 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' |
8319d6ae | 38 | import { FfprobeData } from 'fluent-ffmpeg' |
7b81edc8 | 39 | import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata' |
a7ba16b6 C |
40 | |
41 | const expect = chai.expect | |
0e1dc3e7 C |
42 | |
43 | describe('Test video transcoding', function () { | |
44 | let servers: ServerInfo[] = [] | |
45 | ||
46 | before(async function () { | |
e212f887 | 47 | this.timeout(30000) |
0e1dc3e7 C |
48 | |
49 | // Run servers | |
50 | servers = await flushAndRunMultipleServers(2) | |
51 | ||
52 | await setAccessTokensToServers(servers) | |
b2977eec C |
53 | |
54 | await doubleFollow(servers[0], servers[1]) | |
0e1dc3e7 C |
55 | }) |
56 | ||
57 | it('Should not transcode video on server 1', async function () { | |
58 | this.timeout(60000) | |
59 | ||
60 | const videoAttributes = { | |
975e6e0e C |
61 | name: 'my super name for server 1', |
62 | description: 'my super description for server 1', | |
0e1dc3e7 C |
63 | fixture: 'video_short.webm' |
64 | } | |
65 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | |
66 | ||
3cd0734f | 67 | await waitJobs(servers) |
0e1dc3e7 | 68 | |
b2977eec C |
69 | for (const server of servers) { |
70 | const res = await getVideosList(server.url) | |
a1587156 | 71 | const video = res.body.data[0] |
40298b02 | 72 | |
b2977eec C |
73 | const res2 = await getVideo(server.url, video.id) |
74 | const videoDetails = res2.body | |
75 | expect(videoDetails.files).to.have.lengthOf(1) | |
5f04dd2f | 76 | |
a1587156 | 77 | const magnetUri = videoDetails.files[0].magnetUri |
b2977eec | 78 | expect(magnetUri).to.match(/\.webm/) |
0e1dc3e7 | 79 | |
b2977eec C |
80 | const torrent = await webtorrentAdd(magnetUri, true) |
81 | expect(torrent.files).to.be.an('array') | |
82 | expect(torrent.files.length).to.equal(1) | |
a1587156 | 83 | expect(torrent.files[0].path).match(/\.webm$/) |
b2977eec | 84 | } |
0e1dc3e7 C |
85 | }) |
86 | ||
87 | it('Should transcode video on server 2', async function () { | |
c6c0fa6c | 88 | this.timeout(120000) |
0e1dc3e7 C |
89 | |
90 | const videoAttributes = { | |
975e6e0e C |
91 | name: 'my super name for server 2', |
92 | description: 'my super description for server 2', | |
0e1dc3e7 C |
93 | fixture: 'video_short.webm' |
94 | } | |
95 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
96 | ||
3cd0734f | 97 | await waitJobs(servers) |
0e1dc3e7 | 98 | |
b2977eec C |
99 | for (const server of servers) { |
100 | const res = await getVideosList(server.url) | |
0e1dc3e7 | 101 | |
b2977eec C |
102 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
103 | const res2 = await getVideo(server.url, video.id) | |
104 | const videoDetails = res2.body | |
5f04dd2f | 105 | |
b2977eec | 106 | expect(videoDetails.files).to.have.lengthOf(4) |
40298b02 | 107 | |
a1587156 | 108 | const magnetUri = videoDetails.files[0].magnetUri |
b2977eec | 109 | expect(magnetUri).to.match(/\.mp4/) |
0e1dc3e7 | 110 | |
b2977eec C |
111 | const torrent = await webtorrentAdd(magnetUri, true) |
112 | expect(torrent.files).to.be.an('array') | |
113 | expect(torrent.files.length).to.equal(1) | |
a1587156 | 114 | expect(torrent.files[0].path).match(/\.mp4$/) |
b2977eec | 115 | } |
0e1dc3e7 C |
116 | }) |
117 | ||
7160878c RK |
118 | it('Should transcode high bit rate mp3 to proper bit rate', async function () { |
119 | this.timeout(60000) | |
120 | ||
121 | const videoAttributes = { | |
122 | name: 'mp3_256k', | |
123 | fixture: 'video_short_mp3_256k.mp4' | |
124 | } | |
125 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
126 | ||
127 | await waitJobs(servers) | |
128 | ||
b2977eec C |
129 | for (const server of servers) { |
130 | const res = await getVideosList(server.url) | |
7160878c | 131 | |
b2977eec C |
132 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
133 | const res2 = await getVideo(server.url, video.id) | |
134 | const videoDetails: VideoDetails = res2.body | |
7160878c | 135 | |
b2977eec | 136 | expect(videoDetails.files).to.have.lengthOf(4) |
7160878c | 137 | |
7243f84d | 138 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') |
cdf4cb9e | 139 | const probe = await audio.get(path) |
7160878c | 140 | |
b2977eec | 141 | if (probe.audioStream) { |
a1587156 C |
142 | expect(probe.audioStream['codec_name']).to.be.equal('aac') |
143 | expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000) | |
b2977eec C |
144 | } else { |
145 | this.fail('Could not retrieve the audio stream on ' + probe.absolutePath) | |
146 | } | |
7160878c RK |
147 | } |
148 | }) | |
149 | ||
150 | it('Should transcode video with no audio and have no audio itself', async function () { | |
151 | this.timeout(60000) | |
152 | ||
153 | const videoAttributes = { | |
154 | name: 'no_audio', | |
155 | fixture: 'video_short_no_audio.mp4' | |
156 | } | |
157 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
158 | ||
159 | await waitJobs(servers) | |
160 | ||
b2977eec C |
161 | for (const server of servers) { |
162 | const res = await getVideosList(server.url) | |
7160878c | 163 | |
b2977eec C |
164 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
165 | const res2 = await getVideo(server.url, video.id) | |
166 | const videoDetails: VideoDetails = res2.body | |
7160878c | 167 | |
b2977eec | 168 | expect(videoDetails.files).to.have.lengthOf(4) |
7243f84d | 169 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') |
cdf4cb9e | 170 | const probe = await audio.get(path) |
b2977eec C |
171 | expect(probe).to.not.have.property('audioStream') |
172 | } | |
7160878c RK |
173 | }) |
174 | ||
175 | it('Should leave the audio untouched, but properly transcode the video', async function () { | |
176 | this.timeout(60000) | |
177 | ||
178 | const videoAttributes = { | |
179 | name: 'untouched_audio', | |
180 | fixture: 'video_short.mp4' | |
181 | } | |
182 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
183 | ||
184 | await waitJobs(servers) | |
185 | ||
b2977eec C |
186 | for (const server of servers) { |
187 | const res = await getVideosList(server.url) | |
188 | ||
189 | const video = res.body.data.find(v => v.name === videoAttributes.name) | |
190 | const res2 = await getVideo(server.url, video.id) | |
191 | const videoDetails: VideoDetails = res2.body | |
192 | ||
193 | expect(videoDetails.files).to.have.lengthOf(4) | |
194 | const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) | |
cdf4cb9e | 195 | const fixtureVideoProbe = await audio.get(fixturePath) |
7243f84d | 196 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') |
cdf4cb9e | 197 | const videoProbe = await audio.get(path) |
b2977eec C |
198 | if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { |
199 | const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] | |
200 | expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) | |
201 | } else { | |
202 | this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath) | |
203 | } | |
7160878c RK |
204 | } |
205 | }) | |
206 | ||
3a6f351b | 207 | it('Should transcode a 60 FPS video', async function () { |
73c69591 C |
208 | this.timeout(60000) |
209 | ||
210 | const videoAttributes = { | |
211 | name: 'my super 30fps name for server 2', | |
212 | description: 'my super 30fps description for server 2', | |
3a6f351b | 213 | fixture: '60fps_720p_small.mp4' |
73c69591 C |
214 | } |
215 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
216 | ||
3cd0734f | 217 | await waitJobs(servers) |
73c69591 | 218 | |
b2977eec C |
219 | for (const server of servers) { |
220 | const res = await getVideosList(server.url) | |
73c69591 | 221 | |
b2977eec C |
222 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
223 | const res2 = await getVideo(server.url, video.id) | |
224 | const videoDetails: VideoDetails = res2.body | |
73c69591 | 225 | |
b2977eec | 226 | expect(videoDetails.files).to.have.lengthOf(4) |
a1587156 C |
227 | expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) |
228 | expect(videoDetails.files[1].fps).to.be.below(31) | |
229 | expect(videoDetails.files[2].fps).to.be.below(31) | |
230 | expect(videoDetails.files[3].fps).to.be.below(31) | |
73c69591 | 231 | |
b2977eec | 232 | for (const resolution of [ '240', '360', '480' ]) { |
7243f84d | 233 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') |
b2977eec | 234 | const fps = await getVideoFileFPS(path) |
73c69591 | 235 | |
b2977eec C |
236 | expect(fps).to.be.below(31) |
237 | } | |
3a6f351b | 238 | |
7243f84d | 239 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') |
b2977eec | 240 | const fps = await getVideoFileFPS(path) |
3a6f351b | 241 | |
b2977eec C |
242 | expect(fps).to.be.above(58).and.below(62) |
243 | } | |
73c69591 C |
244 | }) |
245 | ||
edb4ffc7 | 246 | it('Should wait for transcoding before publishing the video', async function () { |
07491f4b | 247 | this.timeout(160000) |
2186386c | 248 | |
2186386c C |
249 | { |
250 | // Upload the video, but wait transcoding | |
251 | const videoAttributes = { | |
252 | name: 'waiting video', | |
253 | fixture: 'video_short1.webm', | |
254 | waitTranscoding: true | |
255 | } | |
a1587156 | 256 | const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) |
2186386c C |
257 | const videoId = resVideo.body.video.uuid |
258 | ||
259 | // Should be in transcode state | |
a1587156 | 260 | const { body } = await getVideo(servers[1].url, videoId) |
2186386c C |
261 | expect(body.name).to.equal('waiting video') |
262 | expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) | |
263 | expect(body.state.label).to.equal('To transcode') | |
264 | expect(body.waitTranscoding).to.be.true | |
265 | ||
266 | // Should have my video | |
267 | const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) | |
7160878c | 268 | const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name) |
2186386c C |
269 | expect(videoToFindInMine).not.to.be.undefined |
270 | expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) | |
271 | expect(videoToFindInMine.state.label).to.equal('To transcode') | |
272 | expect(videoToFindInMine.waitTranscoding).to.be.true | |
273 | ||
274 | // Should not list this video | |
275 | const resVideos = await getVideosList(servers[1].url) | |
7160878c | 276 | const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name) |
2186386c C |
277 | expect(videoToFindInList).to.be.undefined |
278 | ||
279 | // Server 1 should not have the video yet | |
280 | await getVideo(servers[0].url, videoId, 404) | |
281 | } | |
282 | ||
3cd0734f | 283 | await waitJobs(servers) |
2186386c C |
284 | |
285 | for (const server of servers) { | |
286 | const res = await getVideosList(server.url) | |
287 | const videoToFind = res.body.data.find(v => v.name === 'waiting video') | |
288 | expect(videoToFind).not.to.be.undefined | |
289 | ||
290 | const res2 = await getVideo(server.url, videoToFind.id) | |
291 | const videoDetails: VideoDetails = res2.body | |
292 | ||
293 | expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) | |
294 | expect(videoDetails.state.label).to.equal('Published') | |
295 | expect(videoDetails.waitTranscoding).to.be.true | |
296 | } | |
297 | }) | |
298 | ||
edb4ffc7 FA |
299 | it('Should respect maximum bitrate values', async function () { |
300 | this.timeout(160000) | |
301 | ||
74cd011b C |
302 | let tempFixturePath: string |
303 | ||
edb4ffc7 | 304 | { |
74cd011b | 305 | tempFixturePath = await generateHighBitrateVideo() |
edb4ffc7 FA |
306 | |
307 | const bitrate = await getVideoFileBitrate(tempFixturePath) | |
941c5eac | 308 | expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) |
c1c86c15 | 309 | } |
edb4ffc7 | 310 | |
c1c86c15 C |
311 | const videoAttributes = { |
312 | name: 'high bitrate video', | |
313 | description: 'high bitrate video', | |
314 | fixture: tempFixturePath | |
315 | } | |
edb4ffc7 | 316 | |
c1c86c15 | 317 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) |
edb4ffc7 | 318 | |
c1c86c15 | 319 | await waitJobs(servers) |
edb4ffc7 | 320 | |
c1c86c15 C |
321 | for (const server of servers) { |
322 | const res = await getVideosList(server.url) | |
edb4ffc7 | 323 | |
c1c86c15 | 324 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
edb4ffc7 | 325 | |
a1587156 | 326 | for (const resolution of [ '240', '360', '480', '720', '1080' ]) { |
7243f84d | 327 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') |
c1c86c15 C |
328 | const bitrate = await getVideoFileBitrate(path) |
329 | const fps = await getVideoFileFPS(path) | |
330 | const resolution2 = await getVideoFileResolution(path) | |
edb4ffc7 | 331 | |
c1c86c15 C |
332 | expect(resolution2.videoFileResolution.toString()).to.equal(resolution) |
333 | expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) | |
edb4ffc7 FA |
334 | } |
335 | } | |
336 | }) | |
337 | ||
14e2014a C |
338 | it('Should accept and transcode additional extensions', async function () { |
339 | this.timeout(300000) | |
340 | ||
7ed2c1a4 FA |
341 | let tempFixturePath: string |
342 | ||
343 | { | |
344 | tempFixturePath = await generateHighBitrateVideo() | |
345 | ||
346 | const bitrate = await getVideoFileBitrate(tempFixturePath) | |
941c5eac | 347 | expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) |
7ed2c1a4 FA |
348 | } |
349 | ||
14e2014a C |
350 | for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { |
351 | const videoAttributes = { | |
352 | name: fixture, | |
353 | fixture | |
354 | } | |
355 | ||
a1587156 | 356 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) |
14e2014a C |
357 | |
358 | await waitJobs(servers) | |
359 | ||
360 | for (const server of servers) { | |
361 | const res = await getVideosList(server.url) | |
362 | ||
363 | const video = res.body.data.find(v => v.name === videoAttributes.name) | |
364 | const res2 = await getVideo(server.url, video.id) | |
365 | const videoDetails = res2.body | |
366 | ||
367 | expect(videoDetails.files).to.have.lengthOf(4) | |
368 | ||
a1587156 | 369 | const magnetUri = videoDetails.files[0].magnetUri |
14e2014a C |
370 | expect(magnetUri).to.contain('.mp4') |
371 | } | |
372 | } | |
373 | }) | |
374 | ||
7ed2c1a4 FA |
375 | it('Should correctly detect if quick transcode is possible', async function () { |
376 | this.timeout(10000) | |
377 | ||
378 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true | |
379 | expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false | |
380 | }) | |
381 | ||
b345a804 C |
382 | it('Should merge an audio file with the preview file', async function () { |
383 | this.timeout(60000) | |
384 | ||
385 | const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } | |
a1587156 | 386 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
b345a804 C |
387 | |
388 | await waitJobs(servers) | |
389 | ||
390 | for (const server of servers) { | |
391 | const res = await getVideosList(server.url) | |
392 | ||
393 | const video = res.body.data.find(v => v.name === 'audio_with_preview') | |
394 | const res2 = await getVideo(server.url, video.id) | |
395 | const videoDetails: VideoDetails = res2.body | |
396 | ||
397 | expect(videoDetails.files).to.have.lengthOf(1) | |
398 | ||
399 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | |
400 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | |
401 | ||
a1587156 | 402 | const magnetUri = videoDetails.files[0].magnetUri |
b345a804 C |
403 | expect(magnetUri).to.contain('.mp4') |
404 | } | |
405 | }) | |
406 | ||
407 | it('Should upload an audio file and choose a default background image', async function () { | |
408 | this.timeout(60000) | |
409 | ||
410 | const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } | |
a1587156 | 411 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg) |
b345a804 C |
412 | |
413 | await waitJobs(servers) | |
414 | ||
415 | for (const server of servers) { | |
416 | const res = await getVideosList(server.url) | |
417 | ||
418 | const video = res.body.data.find(v => v.name === 'audio_without_preview') | |
419 | const res2 = await getVideo(server.url, video.id) | |
420 | const videoDetails = res2.body | |
421 | ||
422 | expect(videoDetails.files).to.have.lengthOf(1) | |
423 | ||
424 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: 200 }) | |
425 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: 200 }) | |
426 | ||
a1587156 | 427 | const magnetUri = videoDetails.files[0].magnetUri |
b345a804 C |
428 | expect(magnetUri).to.contain('.mp4') |
429 | } | |
430 | }) | |
431 | ||
837666fe RK |
432 | it('Should downscale to the closest divisor standard framerate', async function () { |
433 | this.timeout(160000) | |
434 | ||
435 | let tempFixturePath: string | |
436 | ||
437 | { | |
c7f36e4f | 438 | tempFixturePath = await generateVideoWithFramerate(59) |
837666fe RK |
439 | |
440 | const fps = await getVideoFileFPS(tempFixturePath) | |
441 | expect(fps).to.be.equal(59) | |
442 | } | |
443 | ||
444 | const videoAttributes = { | |
445 | name: '59fps video', | |
446 | description: '59fps video', | |
447 | fixture: tempFixturePath | |
448 | } | |
449 | ||
450 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
451 | ||
452 | await waitJobs(servers) | |
453 | ||
454 | for (const server of servers) { | |
455 | const res = await getVideosList(server.url) | |
456 | ||
457 | const video = res.body.data.find(v => v.name === videoAttributes.name) | |
837666fe | 458 | |
c7f36e4f | 459 | { |
a1587156 | 460 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') |
c7f36e4f C |
461 | const fps = await getVideoFileFPS(path) |
462 | expect(fps).to.be.equal(25) | |
463 | } | |
464 | ||
465 | { | |
a1587156 | 466 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') |
c7f36e4f C |
467 | const fps = await getVideoFileFPS(path) |
468 | expect(fps).to.be.equal(59) | |
469 | } | |
837666fe RK |
470 | } |
471 | }) | |
472 | ||
d218e7de C |
473 | it('Should not transcode to an higher bitrate than the original file', async function () { |
474 | this.timeout(160000) | |
475 | ||
476 | const config = { | |
477 | transcoding: { | |
478 | enabled: true, | |
479 | resolutions: { | |
480 | '240p': true, | |
481 | '360p': true, | |
482 | '480p': true, | |
483 | '720p': true, | |
484 | '1080p': true | |
485 | }, | |
486 | webtorrent: { enabled: true }, | |
487 | hls: { enabled: true } | |
488 | } | |
489 | } | |
490 | await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config) | |
491 | ||
492 | const videoAttributes = { | |
493 | name: 'low bitrate', | |
494 | fixture: 'low-bitrate.mp4' | |
495 | } | |
496 | ||
497 | const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
498 | const videoUUID = resUpload.body.video.uuid | |
499 | ||
500 | await waitJobs(servers) | |
501 | ||
502 | const resolutions = [ 240, 360, 480, 720, 1080 ] | |
503 | for (const r of resolutions) { | |
504 | expect(await getServerFileSize(servers[1], `videos/${videoUUID}-${r}.mp4`)).to.be.below(43) | |
505 | } | |
506 | }) | |
507 | ||
8319d6ae RK |
508 | it('Should provide valid ffprobe data', async function () { |
509 | this.timeout(160000) | |
510 | ||
7b81edc8 | 511 | const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid |
8319d6ae RK |
512 | await waitJobs(servers) |
513 | ||
7b81edc8 C |
514 | { |
515 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') | |
516 | const metadata = await getMetadataFromFile<VideoFileMetadata>(path) | |
8319d6ae | 517 | |
7b81edc8 C |
518 | // expected format properties |
519 | for (const p of [ | |
520 | 'tags.encoder', | |
521 | 'format_long_name', | |
522 | 'size', | |
523 | 'bit_rate' | |
524 | ]) { | |
525 | expect(metadata.format).to.have.nested.property(p) | |
526 | } | |
8319d6ae | 527 | |
7b81edc8 | 528 | // expected stream properties |
8319d6ae | 529 | for (const p of [ |
7b81edc8 C |
530 | 'codec_long_name', |
531 | 'profile', | |
532 | 'width', | |
533 | 'height', | |
534 | 'display_aspect_ratio', | |
535 | 'avg_frame_rate', | |
536 | 'pix_fmt' | |
8319d6ae | 537 | ]) { |
7b81edc8 | 538 | expect(metadata.streams[0]).to.have.nested.property(p) |
8319d6ae | 539 | } |
7b81edc8 | 540 | |
8319d6ae RK |
541 | expect(metadata).to.not.have.nested.property('format.filename') |
542 | } | |
543 | ||
544 | for (const server of servers) { | |
7b81edc8 C |
545 | const res2 = await getVideo(server.url, videoUUID) |
546 | const videoDetails: VideoDetails = res2.body | |
8319d6ae RK |
547 | |
548 | const videoFiles = videoDetails.files | |
7b81edc8 C |
549 | .concat(videoDetails.streamingPlaylists[0].files) |
550 | expect(videoFiles).to.have.lengthOf(8) | |
551 | ||
552 | for (const file of videoFiles) { | |
8319d6ae | 553 | expect(file.metadata).to.be.undefined |
7b81edc8 | 554 | expect(file.metadataUrl).to.exist |
8319d6ae | 555 | expect(file.metadataUrl).to.contain(servers[1].url) |
7b81edc8 | 556 | expect(file.metadataUrl).to.contain(videoUUID) |
8319d6ae RK |
557 | |
558 | const res3 = await getVideoFileMetadataUrl(file.metadataUrl) | |
559 | const metadata: FfprobeData = res3.body | |
560 | expect(metadata).to.have.nested.property('format.size') | |
8319d6ae RK |
561 | } |
562 | } | |
563 | }) | |
564 | ||
7c3b7976 C |
565 | after(async function () { |
566 | await cleanupTests(servers) | |
0e1dc3e7 C |
567 | }) |
568 | }) |