]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
3a149e9f | 2 | |
3a149e9f | 3 | import 'mocha' |
daf6e480 | 4 | import * as chai from 'chai' |
daf6e480 | 5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' |
c55e3d72 C |
6 | import { |
7 | cleanupTests, | |
8 | createMultipleServers, | |
9 | doubleFollow, | |
10 | PeerTubeServer, | |
11 | setAccessTokensToServers, | |
12 | waitJobs | |
13 | } from '@shared/server-commands' | |
3a149e9f C |
14 | |
15 | const expect = chai.expect | |
16 | ||
17 | describe('Test audio only video transcoding', function () { | |
254d3579 | 18 | let servers: PeerTubeServer[] = [] |
3a149e9f | 19 | let videoUUID: string |
83903cb6 C |
20 | let webtorrentAudioFileUrl: string |
21 | let fragmentedAudioFileUrl: string | |
3a149e9f C |
22 | |
23 | before(async function () { | |
24 | this.timeout(120000) | |
25 | ||
26 | const configOverride = { | |
27 | transcoding: { | |
28 | enabled: true, | |
29 | resolutions: { | |
30 | '0p': true, | |
8dd754c7 | 31 | '144p': false, |
3a149e9f C |
32 | '240p': true, |
33 | '360p': false, | |
34 | '480p': false, | |
35 | '720p': false, | |
36 | '1080p': false, | |
b7085c71 | 37 | '1440p': false, |
3a149e9f C |
38 | '2160p': false |
39 | }, | |
40 | hls: { | |
41 | enabled: true | |
42 | }, | |
43 | webtorrent: { | |
44 | enabled: true | |
45 | } | |
46 | } | |
47 | } | |
254d3579 | 48 | servers = await createMultipleServers(2, configOverride) |
3a149e9f C |
49 | |
50 | // Get the access tokens | |
51 | await setAccessTokensToServers(servers) | |
52 | ||
53 | // Server 1 and server 2 follow each other | |
54 | await doubleFollow(servers[0], servers[1]) | |
55 | }) | |
56 | ||
57 | it('Should upload a video and transcode it', async function () { | |
58 | this.timeout(120000) | |
59 | ||
89d241a7 | 60 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } }) |
d23dd9fb | 61 | videoUUID = uuid |
3a149e9f C |
62 | |
63 | await waitJobs(servers) | |
64 | ||
65 | for (const server of servers) { | |
89d241a7 | 66 | const video = await server.videos.get({ id: videoUUID }) |
3a149e9f C |
67 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
68 | ||
69 | for (const files of [ video.files, video.streamingPlaylists[0].files ]) { | |
70 | expect(files).to.have.lengthOf(3) | |
71 | expect(files[0].resolution.id).to.equal(720) | |
72 | expect(files[1].resolution.id).to.equal(240) | |
73 | expect(files[2].resolution.id).to.equal(0) | |
74 | } | |
83903cb6 C |
75 | |
76 | if (server.serverNumber === 1) { | |
77 | webtorrentAudioFileUrl = video.files[2].fileUrl | |
78 | fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl | |
79 | } | |
3a149e9f C |
80 | } |
81 | }) | |
82 | ||
83 | it('0p transcoded video should not have video', async function () { | |
84 | const paths = [ | |
83903cb6 C |
85 | servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl), |
86 | servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl) | |
3a149e9f C |
87 | ] |
88 | ||
89 | for (const path of paths) { | |
daf6e480 | 90 | const { audioStream } = await getAudioStream(path) |
a1587156 C |
91 | expect(audioStream['codec_name']).to.be.equal('aac') |
92 | expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) | |
3a149e9f | 93 | |
52201311 | 94 | const size = await getVideoStreamSize(path) |
3a149e9f C |
95 | expect(size.height).to.equal(0) |
96 | expect(size.width).to.equal(0) | |
97 | } | |
98 | }) | |
99 | ||
100 | after(async function () { | |
101 | await cleanupTests(servers) | |
102 | }) | |
103 | }) |