diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/videos/audio-only.ts | 108 | ||||
-rw-r--r-- | server/tests/api/videos/index.ts | 1 |
2 files changed, 109 insertions, 0 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts new file mode 100644 index 000000000..1ccae4351 --- /dev/null +++ b/server/tests/api/videos/audio-only.ts | |||
@@ -0,0 +1,108 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | checkDirectoryIsEmpty, | ||
7 | checkSegmentHash, | ||
8 | checkTmpIsEmpty, | ||
9 | cleanupTests, | ||
10 | doubleFollow, | ||
11 | flushAndRunMultipleServers, | ||
12 | getPlaylist, | ||
13 | getVideo, makeGetRequest, makeRawRequest, | ||
14 | removeVideo, root, | ||
15 | ServerInfo, | ||
16 | setAccessTokensToServers, updateCustomSubConfig, | ||
17 | updateVideo, | ||
18 | uploadVideo, | ||
19 | waitJobs, webtorrentAdd | ||
20 | } from '../../../../shared/extra-utils' | ||
21 | import { VideoDetails } from '../../../../shared/models/videos' | ||
22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | ||
23 | import { join } from 'path' | ||
24 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | ||
25 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoFileSize } from '@server/helpers/ffmpeg-utils' | ||
26 | |||
27 | const expect = chai.expect | ||
28 | |||
29 | describe('Test audio only video transcoding', function () { | ||
30 | let servers: ServerInfo[] = [] | ||
31 | let videoUUID: string | ||
32 | |||
33 | before(async function () { | ||
34 | this.timeout(120000) | ||
35 | |||
36 | const configOverride = { | ||
37 | transcoding: { | ||
38 | enabled: true, | ||
39 | resolutions: { | ||
40 | '0p': true, | ||
41 | '240p': true, | ||
42 | '360p': false, | ||
43 | '480p': false, | ||
44 | '720p': false, | ||
45 | '1080p': false, | ||
46 | '2160p': false | ||
47 | }, | ||
48 | hls: { | ||
49 | enabled: true | ||
50 | }, | ||
51 | webtorrent: { | ||
52 | enabled: true | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | servers = await flushAndRunMultipleServers(2, configOverride) | ||
57 | |||
58 | // Get the access tokens | ||
59 | await setAccessTokensToServers(servers) | ||
60 | |||
61 | // Server 1 and server 2 follow each other | ||
62 | await doubleFollow(servers[0], servers[1]) | ||
63 | }) | ||
64 | |||
65 | it('Should upload a video and transcode it', async function () { | ||
66 | this.timeout(120000) | ||
67 | |||
68 | const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only'}) | ||
69 | videoUUID = resUpload.body.video.uuid | ||
70 | |||
71 | await waitJobs(servers) | ||
72 | |||
73 | for (const server of servers) { | ||
74 | const res = await getVideo(server.url, videoUUID) | ||
75 | const video: VideoDetails = res.body | ||
76 | |||
77 | expect(video.streamingPlaylists).to.have.lengthOf(1) | ||
78 | |||
79 | for (const files of [ video.files, video.streamingPlaylists[0].files ]) { | ||
80 | expect(files).to.have.lengthOf(3) | ||
81 | expect(files[0].resolution.id).to.equal(720) | ||
82 | expect(files[1].resolution.id).to.equal(240) | ||
83 | expect(files[2].resolution.id).to.equal(0) | ||
84 | } | ||
85 | } | ||
86 | }) | ||
87 | |||
88 | it('0p transcoded video should not have video', async function () { | ||
89 | const paths = [ | ||
90 | join(root(), 'test' + servers[ 0 ].internalServerNumber, 'videos', videoUUID + '-0.mp4'), | ||
91 | join(root(), 'test' + servers[ 0 ].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4') | ||
92 | ] | ||
93 | |||
94 | for (const path of paths) { | ||
95 | const { audioStream } = await audio.get(path) | ||
96 | expect(audioStream[ 'codec_name' ]).to.be.equal('aac') | ||
97 | expect(audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000) | ||
98 | |||
99 | const size = await getVideoFileSize(path) | ||
100 | expect(size.height).to.equal(0) | ||
101 | expect(size.width).to.equal(0) | ||
102 | } | ||
103 | }) | ||
104 | |||
105 | after(async function () { | ||
106 | await cleanupTests(servers) | ||
107 | }) | ||
108 | }) | ||
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 72e6061bb..4d35d3b7c 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import './audio-only' | ||
1 | import './multiple-servers' | 2 | import './multiple-servers' |
2 | import './services' | 3 | import './services' |
3 | import './single-server' | 4 | import './single-server' |