aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/transcoding/audio-only.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /server/tests/api/transcoding/audio-only.ts
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'server/tests/api/transcoding/audio-only.ts')
-rw-r--r--server/tests/api/transcoding/audio-only.ts104
1 files changed, 0 insertions, 104 deletions
diff --git a/server/tests/api/transcoding/audio-only.ts b/server/tests/api/transcoding/audio-only.ts
deleted file mode 100644
index f4cc012ef..000000000
--- a/server/tests/api/transcoding/audio-only.ts
+++ /dev/null
@@ -1,104 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
4import { getAudioStream, getVideoStreamDimensionsInfo } from '@shared/ffmpeg'
5import {
6 cleanupTests,
7 createMultipleServers,
8 doubleFollow,
9 PeerTubeServer,
10 setAccessTokensToServers,
11 waitJobs
12} from '@shared/server-commands'
13
14describe('Test audio only video transcoding', function () {
15 let servers: PeerTubeServer[] = []
16 let videoUUID: string
17 let webVideoAudioFileUrl: string
18 let fragmentedAudioFileUrl: string
19
20 before(async function () {
21 this.timeout(120000)
22
23 const configOverride = {
24 transcoding: {
25 enabled: true,
26 resolutions: {
27 '0p': true,
28 '144p': false,
29 '240p': true,
30 '360p': false,
31 '480p': false,
32 '720p': false,
33 '1080p': false,
34 '1440p': false,
35 '2160p': false
36 },
37 hls: {
38 enabled: true
39 },
40 web_videos: {
41 enabled: true
42 }
43 }
44 }
45 servers = await createMultipleServers(2, configOverride)
46
47 // Get the access tokens
48 await setAccessTokensToServers(servers)
49
50 // Server 1 and server 2 follow each other
51 await doubleFollow(servers[0], servers[1])
52 })
53
54 it('Should upload a video and transcode it', async function () {
55 this.timeout(120000)
56
57 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
58 videoUUID = uuid
59
60 await waitJobs(servers)
61
62 for (const server of servers) {
63 const video = await server.videos.get({ id: videoUUID })
64 expect(video.streamingPlaylists).to.have.lengthOf(1)
65
66 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
67 expect(files).to.have.lengthOf(3)
68 expect(files[0].resolution.id).to.equal(720)
69 expect(files[1].resolution.id).to.equal(240)
70 expect(files[2].resolution.id).to.equal(0)
71 }
72
73 if (server.serverNumber === 1) {
74 webVideoAudioFileUrl = video.files[2].fileUrl
75 fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
76 }
77 }
78 })
79
80 it('0p transcoded video should not have video', async function () {
81 const paths = [
82 servers[0].servers.buildWebVideoFilePath(webVideoAudioFileUrl),
83 servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
84 ]
85
86 for (const path of paths) {
87 const { audioStream } = await getAudioStream(path)
88 expect(audioStream['codec_name']).to.be.equal('aac')
89 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
90
91 const size = await getVideoStreamDimensionsInfo(path)
92
93 expect(size.height).to.equal(0)
94 expect(size.width).to.equal(0)
95 expect(size.isPortraitMode).to.be.false
96 expect(size.ratio).to.equal(0)
97 expect(size.resolution).to.equal(0)
98 }
99 })
100
101 after(async function () {
102 await cleanupTests(servers)
103 })
104})