diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-01-20 20:40:30 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-01-29 13:42:15 +0100 |
commit | 837666fe48f9ed786db75c96e2025cbcf20a1e3b (patch) | |
tree | 3c67248ea0669b18b6861f9630a2070d5d423eb1 /shared/extra-utils | |
parent | 06bcfbd9f715055f2f00bb66149b1dba926d007a (diff) | |
download | PeerTube-837666fe48f9ed786db75c96e2025cbcf20a1e3b.tar.gz PeerTube-837666fe48f9ed786db75c96e2025cbcf20a1e3b.tar.zst PeerTube-837666fe48f9ed786db75c96e2025cbcf20a1e3b.zip |
Add tests for video downscale framerate matching
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index 6b0f6d990..c957a6abe 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -104,6 +104,28 @@ async function generateHighBitrateVideo () { | |||
104 | return tempFixturePath | 104 | return tempFixturePath |
105 | } | 105 | } |
106 | 106 | ||
107 | async function generateVideoWithFramerate (fps = 60) { | ||
108 | const tempFixturePath = buildAbsoluteFixturePath(`video_${fps}fps.mp4`, true) | ||
109 | |||
110 | await ensureDir(dirname(tempFixturePath)) | ||
111 | |||
112 | const exists = await pathExists(tempFixturePath) | ||
113 | if (!exists) { | ||
114 | return new Promise<string>(async (res, rej) => { | ||
115 | ffmpeg() | ||
116 | .outputOptions([ '-f rawvideo', '-video_size 320x240', '-i /dev/urandom' ]) | ||
117 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) | ||
118 | .outputOptions([ `-r ${fps}` ]) | ||
119 | .output(tempFixturePath) | ||
120 | .on('error', rej) | ||
121 | .on('end', () => res(tempFixturePath)) | ||
122 | .run() | ||
123 | }) | ||
124 | } | ||
125 | |||
126 | return tempFixturePath | ||
127 | } | ||
128 | |||
107 | // --------------------------------------------------------------------------- | 129 | // --------------------------------------------------------------------------- |
108 | 130 | ||
109 | export { | 131 | export { |
@@ -115,5 +137,6 @@ export { | |||
115 | testImage, | 137 | testImage, |
116 | buildAbsoluteFixturePath, | 138 | buildAbsoluteFixturePath, |
117 | root, | 139 | root, |
118 | generateHighBitrateVideo | 140 | generateHighBitrateVideo, |
141 | generateVideoWithFramerate | ||
119 | } | 142 | } |