aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-03 17:00:19 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commitb2977eecb8eb5d599df0c6a7ab99a437a6a969c7 (patch)
treeee5f59a932f4395a2e4148e84cdde02cdc32e26f /server/tests
parent590fb5069038e69898123bb795f789683216d837 (diff)
downloadPeerTube-b2977eecb8eb5d599df0c6a7ab99a437a6a969c7.tar.gz
PeerTube-b2977eecb8eb5d599df0c6a7ab99a437a6a969c7.tar.zst
PeerTube-b2977eecb8eb5d599df0c6a7ab99a437a6a969c7.zip
Fix fps federation
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/videos/video-transcoder.ts168
1 files changed, 89 insertions, 79 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 4a39ee3e3..0f83d4d57 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -35,6 +35,8 @@ describe('Test video transcoding', function () {
35 servers = await flushAndRunMultipleServers(2) 35 servers = await flushAndRunMultipleServers(2)
36 36
37 await setAccessTokensToServers(servers) 37 await setAccessTokensToServers(servers)
38
39 await doubleFollow(servers[0], servers[1])
38 }) 40 })
39 41
40 it('Should not transcode video on server 1', async function () { 42 it('Should not transcode video on server 1', async function () {
@@ -49,20 +51,22 @@ describe('Test video transcoding', function () {
49 51
50 await waitJobs(servers) 52 await waitJobs(servers)
51 53
52 const res = await getVideosList(servers[0].url) 54 for (const server of servers) {
53 const video = res.body.data[0] 55 const res = await getVideosList(server.url)
56 const video = res.body.data[ 0 ]
54 57
55 const res2 = await getVideo(servers[0].url, video.id) 58 const res2 = await getVideo(server.url, video.id)
56 const videoDetails = res2.body 59 const videoDetails = res2.body
57 expect(videoDetails.files).to.have.lengthOf(1) 60 expect(videoDetails.files).to.have.lengthOf(1)
58 61
59 const magnetUri = videoDetails.files[0].magnetUri 62 const magnetUri = videoDetails.files[ 0 ].magnetUri
60 expect(magnetUri).to.match(/\.webm/) 63 expect(magnetUri).to.match(/\.webm/)
61 64
62 const torrent = await webtorrentAdd(magnetUri) 65 const torrent = await webtorrentAdd(magnetUri, true)
63 expect(torrent.files).to.be.an('array') 66 expect(torrent.files).to.be.an('array')
64 expect(torrent.files.length).to.equal(1) 67 expect(torrent.files.length).to.equal(1)
65 expect(torrent.files[0].path).match(/\.webm$/) 68 expect(torrent.files[ 0 ].path).match(/\.webm$/)
69 }
66 }) 70 })
67 71
68 it('Should transcode video on server 2', async function () { 72 it('Should transcode video on server 2', async function () {
@@ -77,21 +81,23 @@ describe('Test video transcoding', function () {
77 81
78 await waitJobs(servers) 82 await waitJobs(servers)
79 83
80 const res = await getVideosList(servers[1].url) 84 for (const server of servers) {
85 const res = await getVideosList(server.url)
81 86
82 const video = res.body.data[0] 87 const video = res.body.data.find(v => v.name === videoAttributes.name)
83 const res2 = await getVideo(servers[1].url, video.id) 88 const res2 = await getVideo(server.url, video.id)
84 const videoDetails = res2.body 89 const videoDetails = res2.body
85 90
86 expect(videoDetails.files).to.have.lengthOf(4) 91 expect(videoDetails.files).to.have.lengthOf(4)
87 92
88 const magnetUri = videoDetails.files[0].magnetUri 93 const magnetUri = videoDetails.files[ 0 ].magnetUri
89 expect(magnetUri).to.match(/\.mp4/) 94 expect(magnetUri).to.match(/\.mp4/)
90 95
91 const torrent = await webtorrentAdd(magnetUri) 96 const torrent = await webtorrentAdd(magnetUri, true)
92 expect(torrent.files).to.be.an('array') 97 expect(torrent.files).to.be.an('array')
93 expect(torrent.files.length).to.equal(1) 98 expect(torrent.files.length).to.equal(1)
94 expect(torrent.files[0].path).match(/\.mp4$/) 99 expect(torrent.files[ 0 ].path).match(/\.mp4$/)
100 }
95 }) 101 })
96 102
97 it('Should transcode high bit rate mp3 to proper bit rate', async function () { 103 it('Should transcode high bit rate mp3 to proper bit rate', async function () {
@@ -105,22 +111,24 @@ describe('Test video transcoding', function () {
105 111
106 await waitJobs(servers) 112 await waitJobs(servers)
107 113
108 const res = await getVideosList(servers[1].url) 114 for (const server of servers) {
115 const res = await getVideosList(server.url)
109 116
110 const video = res.body.data.find(v => v.name === videoAttributes.name) 117 const video = res.body.data.find(v => v.name === videoAttributes.name)
111 const res2 = await getVideo(servers[1].url, video.id) 118 const res2 = await getVideo(server.url, video.id)
112 const videoDetails: VideoDetails = res2.body 119 const videoDetails: VideoDetails = res2.body
113 120
114 expect(videoDetails.files).to.have.lengthOf(4) 121 expect(videoDetails.files).to.have.lengthOf(4)
115 122
116 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 123 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
117 const probe = await audio.get(ffmpeg, path) 124 const probe = await audio.get(ffmpeg, path)
118 125
119 if (probe.audioStream) { 126 if (probe.audioStream) {
120 expect(probe.audioStream['codec_name']).to.be.equal('aac') 127 expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac')
121 expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000) 128 expect(probe.audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
122 } else { 129 } else {
123 this.fail('Could not retrieve the audio stream on ' + probe.absolutePath) 130 this.fail('Could not retrieve the audio stream on ' + probe.absolutePath)
131 }
124 } 132 }
125 }) 133 })
126 134
@@ -135,16 +143,18 @@ describe('Test video transcoding', function () {
135 143
136 await waitJobs(servers) 144 await waitJobs(servers)
137 145
138 const res = await getVideosList(servers[1].url) 146 for (const server of servers) {
147 const res = await getVideosList(server.url)
139 148
140 const video = res.body.data.find(v => v.name === videoAttributes.name) 149 const video = res.body.data.find(v => v.name === videoAttributes.name)
141 const res2 = await getVideo(servers[1].url, video.id) 150 const res2 = await getVideo(server.url, video.id)
142 const videoDetails: VideoDetails = res2.body 151 const videoDetails: VideoDetails = res2.body
143 152
144 expect(videoDetails.files).to.have.lengthOf(4) 153 expect(videoDetails.files).to.have.lengthOf(4)
145 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 154 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
146 const probe = await audio.get(ffmpeg, path) 155 const probe = await audio.get(ffmpeg, path)
147 expect(probe).to.not.have.property('audioStream') 156 expect(probe).to.not.have.property('audioStream')
157 }
148 }) 158 })
149 159
150 it('Should leave the audio untouched, but properly transcode the video', async function () { 160 it('Should leave the audio untouched, but properly transcode the video', async function () {
@@ -158,22 +168,24 @@ describe('Test video transcoding', function () {
158 168
159 await waitJobs(servers) 169 await waitJobs(servers)
160 170
161 const res = await getVideosList(servers[1].url) 171 for (const server of servers) {
162 172 const res = await getVideosList(server.url)
163 const video = res.body.data.find(v => v.name === videoAttributes.name) 173
164 const res2 = await getVideo(servers[1].url, video.id) 174 const video = res.body.data.find(v => v.name === videoAttributes.name)
165 const videoDetails: VideoDetails = res2.body 175 const res2 = await getVideo(server.url, video.id)
166 176 const videoDetails: VideoDetails = res2.body
167 expect(videoDetails.files).to.have.lengthOf(4) 177
168 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 178 expect(videoDetails.files).to.have.lengthOf(4)
169 const fixtureVideoProbe = await audio.get(ffmpeg, fixturePath) 179 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
170 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 180 const fixtureVideoProbe = await audio.get(ffmpeg, fixturePath)
171 const videoProbe = await audio.get(ffmpeg, path) 181 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
172 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { 182 const videoProbe = await audio.get(ffmpeg, path)
173 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] 183 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
174 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) 184 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
175 } else { 185 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
176 this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath) 186 } else {
187 this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath)
188 }
177 } 189 }
178 }) 190 })
179 191
@@ -189,38 +201,36 @@ describe('Test video transcoding', function () {
189 201
190 await waitJobs(servers) 202 await waitJobs(servers)
191 203
192 const res = await getVideosList(servers[1].url) 204 for (const server of servers) {
205 const res = await getVideosList(server.url)
193 206
194 const video = res.body.data.find(v => v.name === videoAttributes.name) 207 const video = res.body.data.find(v => v.name === videoAttributes.name)
195 const res2 = await getVideo(servers[1].url, video.id) 208 const res2 = await getVideo(server.url, video.id)
196 const videoDetails: VideoDetails = res2.body 209 const videoDetails: VideoDetails = res2.body
197 210
198 expect(videoDetails.files).to.have.lengthOf(4) 211 expect(videoDetails.files).to.have.lengthOf(4)
199 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) 212 expect(videoDetails.files[ 0 ].fps).to.be.above(58).and.below(62)
200 expect(videoDetails.files[1].fps).to.be.below(31) 213 expect(videoDetails.files[ 1 ].fps).to.be.below(31)
201 expect(videoDetails.files[2].fps).to.be.below(31) 214 expect(videoDetails.files[ 2 ].fps).to.be.below(31)
202 expect(videoDetails.files[3].fps).to.be.below(31) 215 expect(videoDetails.files[ 3 ].fps).to.be.below(31)
203 216
204 for (const resolution of [ '240', '360', '480' ]) { 217 for (const resolution of [ '240', '360', '480' ]) {
205 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') 218 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4')
206 const fps = await getVideoFileFPS(path) 219 const fps = await getVideoFileFPS(path)
207 220
208 expect(fps).to.be.below(31) 221 expect(fps).to.be.below(31)
209 } 222 }
210 223
211 const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') 224 const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4')
212 const fps = await getVideoFileFPS(path) 225 const fps = await getVideoFileFPS(path)
213 226
214 expect(fps).to.be.above(58).and.below(62) 227 expect(fps).to.be.above(58).and.below(62)
228 }
215 }) 229 })
216 230
217 it('Should wait transcoding before publishing the video', async function () { 231 it('Should wait transcoding before publishing the video', async function () {
218 this.timeout(80000) 232 this.timeout(80000)
219 233
220 await doubleFollow(servers[0], servers[1])
221
222 await waitJobs(servers)
223
224 { 234 {
225 // Upload the video, but wait transcoding 235 // Upload the video, but wait transcoding
226 const videoAttributes = { 236 const videoAttributes = {