+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getVideosList(server.url)
+
+ const video = res.body.data.find(v => v.name === videoAttributes.name)
+ const res2 = await getVideo(server.url, video.id)
+ const videoDetails = res2.body
+
+ expect(videoDetails.files).to.have.lengthOf(4)
+
+ const magnetUri = videoDetails.files[ 0 ].magnetUri
+ expect(magnetUri).to.match(/\.mp4/)
+
+ const torrent = await webtorrentAdd(magnetUri, true)
+ expect(torrent.files).to.be.an('array')
+ expect(torrent.files.length).to.equal(1)
+ expect(torrent.files[ 0 ].path).match(/\.mp4$/)
+ }
+ })
+
+ it('Should transcode high bit rate mp3 to proper bit rate', async function () {
+ this.timeout(60000)
+
+ const videoAttributes = {
+ name: 'mp3_256k',
+ fixture: 'video_short_mp3_256k.mp4'
+ }
+ await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getVideosList(server.url)
+
+ const video = res.body.data.find(v => v.name === videoAttributes.name)
+ const res2 = await getVideo(server.url, video.id)
+ const videoDetails: VideoDetails = res2.body
+
+ expect(videoDetails.files).to.have.lengthOf(4)
+
+ const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
+ const probe = await audio.get(path)
+
+ if (probe.audioStream) {
+ expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac')
+ expect(probe.audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
+ } else {
+ this.fail('Could not retrieve the audio stream on ' + probe.absolutePath)
+ }
+ }
+ })
+
+ it('Should transcode video with no audio and have no audio itself', async function () {
+ this.timeout(60000)
+
+ const videoAttributes = {
+ name: 'no_audio',
+ fixture: 'video_short_no_audio.mp4'
+ }
+ await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const res = await getVideosList(server.url)
+
+ const video = res.body.data.find(v => v.name === videoAttributes.name)
+ const res2 = await getVideo(server.url, video.id)
+ const videoDetails: VideoDetails = res2.body
+
+ expect(videoDetails.files).to.have.lengthOf(4)
+ const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
+ const probe = await audio.get(path)
+ expect(probe).to.not.have.property('audioStream')
+ }
+ })
+
+ it('Should leave the audio untouched, but properly transcode the video', async function () {
+ this.timeout(60000)