aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/transcoding/audio-only.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-02-28 15:56:51 +0100
committerChocobozzz <me@florianbigard.com>2022-02-28 16:02:08 +0100
commit95faf1eafffff4fe1f74025092c7c3eef2951697 (patch)
tree8a18d271200d2c87ea5fff6b1f97efcda69d2f21 /server/tests/api/transcoding/audio-only.ts
parentcba7977552e909ea0ea4dc526788a9166ad5f535 (diff)
downloadPeerTube-95faf1eafffff4fe1f74025092c7c3eef2951697.tar.gz
PeerTube-95faf1eafffff4fe1f74025092c7c3eef2951697.tar.zst
PeerTube-95faf1eafffff4fe1f74025092c7c3eef2951697.zip
Create another test suite for transcoding jobs
Diffstat (limited to 'server/tests/api/transcoding/audio-only.ts')
-rw-r--r--server/tests/api/transcoding/audio-only.ts102
1 files changed, 102 insertions, 0 deletions
diff --git a/server/tests/api/transcoding/audio-only.ts b/server/tests/api/transcoding/audio-only.ts
new file mode 100644
index 000000000..e7e73d382
--- /dev/null
+++ b/server/tests/api/transcoding/audio-only.ts
@@ -0,0 +1,102 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import * as chai from 'chai'
5import { getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg'
6import {
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 PeerTubeServer,
11 setAccessTokensToServers,
12 waitJobs
13} from '@shared/server-commands'
14
15const expect = chai.expect
16
17describe('Test audio only video transcoding', function () {
18 let servers: PeerTubeServer[] = []
19 let videoUUID: string
20 let webtorrentAudioFileUrl: string
21 let fragmentedAudioFileUrl: string
22
23 before(async function () {
24 this.timeout(120000)
25
26 const configOverride = {
27 transcoding: {
28 enabled: true,
29 resolutions: {
30 '0p': true,
31 '144p': false,
32 '240p': true,
33 '360p': false,
34 '480p': false,
35 '720p': false,
36 '1080p': false,
37 '1440p': false,
38 '2160p': false
39 },
40 hls: {
41 enabled: true
42 },
43 webtorrent: {
44 enabled: true
45 }
46 }
47 }
48 servers = await createMultipleServers(2, configOverride)
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
60 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
61 videoUUID = uuid
62
63 await waitJobs(servers)
64
65 for (const server of servers) {
66 const video = await server.videos.get({ id: videoUUID })
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 }
75
76 if (server.serverNumber === 1) {
77 webtorrentAudioFileUrl = video.files[2].fileUrl
78 fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
79 }
80 }
81 })
82
83 it('0p transcoded video should not have video', async function () {
84 const paths = [
85 servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl),
86 servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
87 ]
88
89 for (const path of paths) {
90 const { audioStream } = await getAudioStream(path)
91 expect(audioStream['codec_name']).to.be.equal('aac')
92 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
93
94 const size = await getVideoStreamDimensionsInfo(path)
95 expect(size).to.not.exist
96 }
97 })
98
99 after(async function () {
100 await cleanupTests(servers)
101 })
102})