aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-18 16:53:52 +0200
committerChocobozzz <me@florianbigard.com>2018-10-18 16:54:26 +0200
commit74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15 (patch)
tree0fa74ef54f80cf5b2825f0b2d2d123e4c1aaa1dc /server/tests/api/videos
parentccbbe2b8d4b18d48d132058776c22397250a4a87 (diff)
downloadPeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.tar.gz
PeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.tar.zst
PeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.zip
Fix optimize old videos script
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-transcoder.ts25
1 files changed, 5 insertions, 20 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 0a567873c..85795d2ed 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -18,7 +18,8 @@ import {
18 ServerInfo, 18 ServerInfo,
19 setAccessTokensToServers, 19 setAccessTokensToServers,
20 uploadVideo, 20 uploadVideo,
21 webtorrentAdd 21 webtorrentAdd,
22 generateHighBitrateVideo
22} from '../../utils' 23} from '../../utils'
23import { join } from 'path' 24import { join } from 'path'
24import { waitJobs } from '../../utils/server/jobs' 25import { waitJobs } from '../../utils/server/jobs'
@@ -283,29 +284,13 @@ describe('Test video transcoding', function () {
283 } 284 }
284 }) 285 })
285 286
286 const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
287 it('Should respect maximum bitrate values', async function () { 287 it('Should respect maximum bitrate values', async function () {
288 this.timeout(160000) 288 this.timeout(160000)
289 289
290 let tempFixturePath: string
291
290 { 292 {
291 const exists = await pathExists(tempFixturePath) 293 tempFixturePath = await generateHighBitrateVideo()
292 if (!exists) {
293
294 // Generate a random, high bitrate video on the fly, so we don't have to include
295 // a large file in the repo. The video needs to have a certain minimum length so
296 // that FFmpeg properly applies bitrate limits.
297 // https://stackoverflow.com/a/15795112
298 await new Promise<void>(async (res, rej) => {
299 ffmpeg()
300 .outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ])
301 .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
302 .outputOptions([ '-maxrate 10M', '-bufsize 10M' ])
303 .output(tempFixturePath)
304 .on('error', rej)
305 .on('end', res)
306 .run()
307 })
308 }
309 294
310 const bitrate = await getVideoFileBitrate(tempFixturePath) 295 const bitrate = await getVideoFileBitrate(tempFixturePath)
311 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS)) 296 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS))