aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-22 11:43:17 +0100
committerChocobozzz <me@florianbigard.com>2019-11-25 10:59:49 +0100
commit3a149e9f8b2e99507c72792b80cee3a90df003b2 (patch)
treee12d6279f8a9cb3c3268aa7a006b22a85c42d034 /server/tests/api/videos
parent6ad88df896e359e428259ff511f6fca3675cb4af (diff)
downloadPeerTube-3a149e9f8b2e99507c72792b80cee3a90df003b2.tar.gz
PeerTube-3a149e9f8b2e99507c72792b80cee3a90df003b2.tar.zst
PeerTube-3a149e9f8b2e99507c72792b80cee3a90df003b2.zip
Add audio only transcoding tests
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/audio-only.ts108
-rw-r--r--server/tests/api/videos/index.ts1
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
3import * as chai from 'chai'
4import 'mocha'
5import {
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'
21import { VideoDetails } from '../../../../shared/models/videos'
22import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
23import { join } from 'path'
24import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
25import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoFileSize } from '@server/helpers/ffmpeg-utils'
26
27const expect = chai.expect
28
29describe('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 @@
1import './audio-only'
1import './multiple-servers' 2import './multiple-servers'
2import './services' 3import './services'
3import './single-server' 4import './single-server'