- const resolutions = [ 240, 360, 480, 720, 1080 ]
- for (const r of resolutions) {
- expect(await getServerFileSize(servers[1], `videos/${videoUUID}-${r}.mp4`)).to.be.below(60000)
- }
+ const { id } = data.find(v => v.name === attributes.name)
+ const video = await server.videos.get({ id })
+
+ for (const resolution of [ 240, 360, 480, 720, 1080 ]) {
+ const file = video.files.find(f => f.resolution.id === resolution)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
+
+ const bitrate = await getVideoFileBitrate(path)
+ const fps = await getVideoFileFPS(path)
+ const dataResolution = await getVideoFileResolution(path)
+
+ expect(resolution).to.equal(resolution)
+
+ const maxBitrate = getMaxBitrate({ ...dataResolution, fps })
+ expect(bitrate).to.be.below(maxBitrate)
+ }
+ }
+ })
+
+ it('Should not transcode to an higher bitrate than the original file', async function () {
+ this.timeout(160_000)
+
+ const newConfig = {
+ transcoding: {
+ enabled: true,
+ resolutions: {
+ '240p': true,
+ '360p': true,
+ '480p': true,
+ '720p': true,
+ '1080p': true,
+ '1440p': true,
+ '2160p': true
+ },
+ webtorrent: { enabled: true },
+ hls: { enabled: true }
+ }
+ }
+ await servers[1].config.updateCustomSubConfig({ newConfig })
+
+ const attributes = {
+ name: 'low bitrate',
+ fixture: 'low-bitrate.mp4'
+ }
+
+ const { id } = await servers[1].videos.upload({ attributes })
+
+ await waitJobs(servers)
+
+ const video = await servers[1].videos.get({ id })
+
+ const resolutions = [ 240, 360, 480, 720, 1080 ]
+ for (const r of resolutions) {
+ const file = video.files.find(f => f.resolution.id === r)
+
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
+ const bitrate = await getVideoFileBitrate(path)
+ expect(bitrate, `${path} not below ${60_000}`).to.be.below(60_000)
+ }
+ })