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