aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/initializers/checker-before-init.ts2
-rw-r--r--server/lib/video-transcoding-profiles.ts3
-rw-r--r--server/tests/api/live/live.ts22
-rw-r--r--server/tests/api/videos/audio-only.ts6
-rw-r--r--server/tests/api/videos/video-transcoder.ts25
-rw-r--r--server/tests/cli/optimize-old-videos.ts4
-rw-r--r--server/tests/cli/prune-storage.ts14
-rw-r--r--shared/extra-utils/miscs/miscs.ts8
-rw-r--r--shared/extra-utils/server/plugins.ts12
-rw-r--r--shared/extra-utils/server/servers.ts6
-rw-r--r--shared/extra-utils/videos/live.ts10
-rw-r--r--shared/extra-utils/videos/videos.ts15
12 files changed, 70 insertions, 57 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 4ffd6fad9..b04f3e538 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -82,8 +82,6 @@ function checkMissedConfig () {
82async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { 82async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
83 if (CONFIG.TRANSCODING.ENABLED === false) return undefined 83 if (CONFIG.TRANSCODING.ENABLED === false) return undefined
84 84
85 checkFFmpegEncoders()
86
87 const Ffmpeg = require('fluent-ffmpeg') 85 const Ffmpeg = require('fluent-ffmpeg')
88 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) 86 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
89 const codecs = await getAvailableCodecsPromise() 87 const codecs = await getAvailableCodecsPromise()
diff --git a/server/lib/video-transcoding-profiles.ts b/server/lib/video-transcoding-profiles.ts
index 12e22a19d..91a5c65f2 100644
--- a/server/lib/video-transcoding-profiles.ts
+++ b/server/lib/video-transcoding-profiles.ts
@@ -38,7 +38,8 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = async ({ resolution
38 return { 38 return {
39 outputOptions: [ 39 outputOptions: [
40 `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`, 40 `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`,
41 `-maxrate ${targetBitrate}`, `-bufsize ${targetBitrate * 2}` 41 `-maxrate ${targetBitrate}`,
42 `-bufsize ${targetBitrate * 2}`
42 ] 43 ]
43 } 44 }
44} 45}
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index ac91b6b08..e685be08e 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -3,10 +3,13 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { join } from 'path'
7import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
6import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io' 8import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 9import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
8import { 10import {
9 addVideoToBlacklist, 11 addVideoToBlacklist,
12 buildServerDirectory,
10 checkLiveCleanup, 13 checkLiveCleanup,
11 checkLiveSegmentHash, 14 checkLiveSegmentHash,
12 checkResolutionsInMasterPlaylist, 15 checkResolutionsInMasterPlaylist,
@@ -396,10 +399,11 @@ describe('Test live', function () {
396 this.timeout(60000) 399 this.timeout(60000)
397 400
398 const resolutions = [ 240, 360, 720 ] 401 const resolutions = [ 240, 360, 720 ]
402
399 await updateConf(resolutions) 403 await updateConf(resolutions)
400 liveVideoId = await createLiveWrapper(true) 404 liveVideoId = await createLiveWrapper(true)
401 405
402 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 406 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
403 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) 407 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
404 await waitJobs(servers) 408 await waitJobs(servers)
405 409
@@ -409,6 +413,12 @@ describe('Test live', function () {
409 413
410 await waitJobs(servers) 414 await waitJobs(servers)
411 415
416 const bitrateLimits = {
417 720: 2800 * 1000,
418 360: 780 * 1000,
419 240: 320 * 1000
420 }
421
412 for (const server of servers) { 422 for (const server of servers) {
413 const resVideo = await getVideo(server.url, liveVideoId) 423 const resVideo = await getVideo(server.url, liveVideoId)
414 const video: VideoDetails = resVideo.body 424 const video: VideoDetails = resVideo.body
@@ -424,9 +434,17 @@ describe('Test live', function () {
424 const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) 434 const file = hlsPlaylist.files.find(f => f.resolution.id === resolution)
425 435
426 expect(file).to.exist 436 expect(file).to.exist
427 expect(file.fps).to.be.oneOf([ 24, 25 ]) 437 expect(file.fps).to.be.approximately(30, 5)
428 expect(file.size).to.be.greaterThan(1) 438 expect(file.size).to.be.greaterThan(1)
429 439
440 const filename = `${video.uuid}-${resolution}-fragmented.mp4`
441 const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename))
442
443 const probe = await ffprobePromise(segmentPath)
444 const videoStream = await getVideoStreamFromFile(segmentPath, probe)
445 console.log(videoStream)
446 expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height])
447
430 await makeRawRequest(file.torrentUrl, 200) 448 await makeRawRequest(file.torrentUrl, 200)
431 await makeRawRequest(file.fileUrl, 200) 449 await makeRawRequest(file.fileUrl, 200)
432 } 450 }
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index 053b29ca1..294a00112 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -5,11 +5,11 @@ import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 buildServerDirectory,
8 cleanupTests, 9 cleanupTests,
9 doubleFollow, 10 doubleFollow,
10 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
11 getVideo, 12 getVideo,
12 root,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 uploadVideo, 15 uploadVideo,
@@ -80,8 +80,8 @@ describe('Test audio only video transcoding', function () {
80 80
81 it('0p transcoded video should not have video', async function () { 81 it('0p transcoded video should not have video', async function () {
82 const paths = [ 82 const paths = [
83 join(root(), 'test' + servers[0].internalServerNumber, 'videos', videoUUID + '-0.mp4'), 83 buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')),
84 join(root(), 'test' + servers[0].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4') 84 buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
85 ] 85 ]
86 86
87 for (const path of paths) { 87 for (const path of paths) {
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 3e336e786..164843d32 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -5,10 +5,10 @@ import * as chai from 'chai'
5import { FfprobeData } from 'fluent-ffmpeg' 5import { FfprobeData } from 'fluent-ffmpeg'
6import { omit } from 'lodash' 6import { omit } from 'lodash'
7import { join } from 'path' 7import { join } from 'path'
8
9import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 8import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
10import { 9import {
11 buildAbsoluteFixturePath, 10 buildAbsoluteFixturePath,
11 buildServerDirectory,
12 cleanupTests, 12 cleanupTests,
13 doubleFollow, 13 doubleFollow,
14 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
@@ -20,7 +20,6 @@ import {
20 getVideoFileMetadataUrl, 20 getVideoFileMetadataUrl,
21 getVideosList, 21 getVideosList,
22 makeGetRequest, 22 makeGetRequest,
23 root,
24 ServerInfo, 23 ServerInfo,
25 setAccessTokensToServers, 24 setAccessTokensToServers,
26 updateCustomSubConfig, 25 updateCustomSubConfig,
@@ -136,7 +135,7 @@ describe('Test video transcoding', function () {
136 135
137 expect(videoDetails.files).to.have.lengthOf(4) 136 expect(videoDetails.files).to.have.lengthOf(4)
138 137
139 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 138 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
140 const probe = await getAudioStream(path) 139 const probe = await getAudioStream(path)
141 140
142 if (probe.audioStream) { 141 if (probe.audioStream) {
@@ -167,7 +166,7 @@ describe('Test video transcoding', function () {
167 const videoDetails: VideoDetails = res2.body 166 const videoDetails: VideoDetails = res2.body
168 167
169 expect(videoDetails.files).to.have.lengthOf(4) 168 expect(videoDetails.files).to.have.lengthOf(4)
170 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 169 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
171 const probe = await getAudioStream(path) 170 const probe = await getAudioStream(path)
172 expect(probe).to.not.have.property('audioStream') 171 expect(probe).to.not.have.property('audioStream')
173 } 172 }
@@ -192,10 +191,13 @@ describe('Test video transcoding', function () {
192 const videoDetails: VideoDetails = res2.body 191 const videoDetails: VideoDetails = res2.body
193 192
194 expect(videoDetails.files).to.have.lengthOf(4) 193 expect(videoDetails.files).to.have.lengthOf(4)
194
195 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 195 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
196 const fixtureVideoProbe = await getAudioStream(fixturePath) 196 const fixtureVideoProbe = await getAudioStream(fixturePath)
197 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 197 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
198
198 const videoProbe = await getAudioStream(path) 199 const videoProbe = await getAudioStream(path)
200
199 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { 201 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
200 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] 202 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
201 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) 203 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
@@ -231,13 +233,13 @@ describe('Test video transcoding', function () {
231 expect(videoDetails.files[3].fps).to.be.below(31) 233 expect(videoDetails.files[3].fps).to.be.below(31)
232 234
233 for (const resolution of [ '240', '360', '480' ]) { 235 for (const resolution of [ '240', '360', '480' ]) {
234 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') 236 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
235 const fps = await getVideoFileFPS(path) 237 const fps = await getVideoFileFPS(path)
236 238
237 expect(fps).to.be.below(31) 239 expect(fps).to.be.below(31)
238 } 240 }
239 241
240 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') 242 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
241 const fps = await getVideoFileFPS(path) 243 const fps = await getVideoFileFPS(path)
242 244
243 expect(fps).to.be.above(58).and.below(62) 245 expect(fps).to.be.above(58).and.below(62)
@@ -325,7 +327,8 @@ describe('Test video transcoding', function () {
325 const video = res.body.data.find(v => v.name === videoAttributes.name) 327 const video = res.body.data.find(v => v.name === videoAttributes.name)
326 328
327 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 329 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
328 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') 330 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
331
329 const bitrate = await getVideoFileBitrate(path) 332 const bitrate = await getVideoFileBitrate(path)
330 const fps = await getVideoFileFPS(path) 333 const fps = await getVideoFileFPS(path)
331 const resolution2 = await getVideoFileResolution(path) 334 const resolution2 = await getVideoFileResolution(path)
@@ -458,13 +461,13 @@ describe('Test video transcoding', function () {
458 const video = res.body.data.find(v => v.name === videoAttributes.name) 461 const video = res.body.data.find(v => v.name === videoAttributes.name)
459 462
460 { 463 {
461 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 464 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
462 const fps = await getVideoFileFPS(path) 465 const fps = await getVideoFileFPS(path)
463 expect(fps).to.be.equal(25) 466 expect(fps).to.be.equal(25)
464 } 467 }
465 468
466 { 469 {
467 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') 470 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
468 const fps = await getVideoFileFPS(path) 471 const fps = await getVideoFileFPS(path)
469 expect(fps).to.be.equal(59) 472 expect(fps).to.be.equal(59)
470 } 473 }
@@ -513,7 +516,7 @@ describe('Test video transcoding', function () {
513 await waitJobs(servers) 516 await waitJobs(servers)
514 517
515 { 518 {
516 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') 519 const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4'))
517 const metadata = await getMetadataFromFile(path) 520 const metadata = await getMetadataFromFile(path)
518 521
519 // expected format properties 522 // expected format properties
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 420fb8049..91a1c9cc4 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { 6import {
7 buildServerDirectory,
7 cleanupTests, 8 cleanupTests,
8 doubleFollow, 9 doubleFollow,
9 execCLI, 10 execCLI,
@@ -12,7 +13,6 @@ import {
12 getEnvCli, 13 getEnvCli,
13 getVideo, 14 getVideo,
14 getVideosList, 15 getVideosList,
15 root,
16 ServerInfo, 16 ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 uploadVideo, 18 uploadVideo,
@@ -100,7 +100,7 @@ describe('Test optimize old videos', function () {
100 100
101 expect(file.size).to.be.below(8000000) 101 expect(file.size).to.be.below(8000000)
102 102
103 const path = join(root(), 'test' + servers[0].internalServerNumber, 'videos', video.uuid + '-' + file.resolution.id + '.mp4') 103 const path = buildServerDirectory(servers[0], join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
104 const bitrate = await getVideoFileBitrate(path) 104 const bitrate = await getVideoFileBitrate(path)
105 const fps = await getVideoFileFPS(path) 105 const fps = await getVideoFileFPS(path)
106 const resolution = await getVideoFileResolution(path) 106 const resolution = await getVideoFileResolution(path)
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index 6cda80070..052a5f91e 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -28,13 +28,13 @@ import { join } from 'path'
28const expect = chai.expect 28const expect = chai.expect
29 29
30async function countFiles (internalServerNumber: number, directory: string) { 30async function countFiles (internalServerNumber: number, directory: string) {
31 const files = await readdir(buildServerDirectory(internalServerNumber, directory)) 31 const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
32 32
33 return files.length 33 return files.length
34} 34}
35 35
36async function assertNotExists (internalServerNumber: number, directory: string, substring: string) { 36async function assertNotExists (internalServerNumber: number, directory: string, substring: string) {
37 const files = await readdir(buildServerDirectory(internalServerNumber, directory)) 37 const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
38 38
39 for (const f of files) { 39 for (const f of files) {
40 expect(f).to.not.contain(substring) 40 expect(f).to.not.contain(substring)
@@ -124,7 +124,7 @@ describe('Test prune storage scripts', function () {
124 it('Should create some dirty files', async function () { 124 it('Should create some dirty files', async function () {
125 for (let i = 0; i < 2; i++) { 125 for (let i = 0; i < 2; i++) {
126 { 126 {
127 const base = buildServerDirectory(servers[0].internalServerNumber, 'videos') 127 const base = buildServerDirectory(servers[0], 'videos')
128 128
129 const n1 = uuidv4() + '.mp4' 129 const n1 = uuidv4() + '.mp4'
130 const n2 = uuidv4() + '.webm' 130 const n2 = uuidv4() + '.webm'
@@ -136,7 +136,7 @@ describe('Test prune storage scripts', function () {
136 } 136 }
137 137
138 { 138 {
139 const base = buildServerDirectory(servers[0].internalServerNumber, 'torrents') 139 const base = buildServerDirectory(servers[0], 'torrents')
140 140
141 const n1 = uuidv4() + '-240.torrent' 141 const n1 = uuidv4() + '-240.torrent'
142 const n2 = uuidv4() + '-480.torrent' 142 const n2 = uuidv4() + '-480.torrent'
@@ -148,7 +148,7 @@ describe('Test prune storage scripts', function () {
148 } 148 }
149 149
150 { 150 {
151 const base = buildServerDirectory(servers[0].internalServerNumber, 'thumbnails') 151 const base = buildServerDirectory(servers[0], 'thumbnails')
152 152
153 const n1 = uuidv4() + '.jpg' 153 const n1 = uuidv4() + '.jpg'
154 const n2 = uuidv4() + '.jpg' 154 const n2 = uuidv4() + '.jpg'
@@ -160,7 +160,7 @@ describe('Test prune storage scripts', function () {
160 } 160 }
161 161
162 { 162 {
163 const base = buildServerDirectory(servers[0].internalServerNumber, 'previews') 163 const base = buildServerDirectory(servers[0], 'previews')
164 164
165 const n1 = uuidv4() + '.jpg' 165 const n1 = uuidv4() + '.jpg'
166 const n2 = uuidv4() + '.jpg' 166 const n2 = uuidv4() + '.jpg'
@@ -172,7 +172,7 @@ describe('Test prune storage scripts', function () {
172 } 172 }
173 173
174 { 174 {
175 const base = buildServerDirectory(servers[0].internalServerNumber, 'avatars') 175 const base = buildServerDirectory(servers[0], 'avatars')
176 176
177 const n1 = uuidv4() + '.png' 177 const n1 = uuidv4() + '.png'
178 const n2 = uuidv4() + '.jpg' 178 const n2 = uuidv4() + '.jpg'
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts
index 3c8191ae8..429083fe9 100644
--- a/shared/extra-utils/miscs/miscs.ts
+++ b/shared/extra-utils/miscs/miscs.ts
@@ -1,11 +1,11 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import * as ffmpeg from 'fluent-ffmpeg'
5import { ensureDir, pathExists, readFile, stat } from 'fs-extra'
4import { basename, dirname, isAbsolute, join, resolve } from 'path' 6import { basename, dirname, isAbsolute, join, resolve } from 'path'
5import * as request from 'supertest' 7import * as request from 'supertest'
6import * as WebTorrent from 'webtorrent' 8import * as WebTorrent from 'webtorrent'
7import { ensureDir, pathExists, readFile, stat } from 'fs-extra'
8import * as ffmpeg from 'fluent-ffmpeg'
9 9
10const expect = chai.expect 10const expect = chai.expect
11let webtorrent: WebTorrent.Instance 11let webtorrent: WebTorrent.Instance
@@ -44,8 +44,8 @@ function root () {
44 return root 44 return root
45} 45}
46 46
47function buildServerDirectory (internalServerNumber: number, directory: string) { 47function buildServerDirectory (server: { internalServerNumber: number }, directory: string) {
48 return join(root(), 'test' + internalServerNumber, directory) 48 return join(root(), 'test' + server.internalServerNumber, directory)
49} 49}
50 50
51async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { 51async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index b6b5e3958..8f370f655 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -1,10 +1,10 @@
1import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
2import { PluginType } from '../../models/plugins/plugin.type'
3import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model'
4import { readJSON, writeJSON } from 'fs-extra' 1import { readJSON, writeJSON } from 'fs-extra'
5import { ServerInfo } from './servers'
6import { root } from '../miscs/miscs'
7import { join } from 'path' 2import { join } from 'path'
3import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model'
4import { PluginType } from '../../models/plugins/plugin.type'
5import { buildServerDirectory, root } from '../miscs/miscs'
6import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
7import { ServerInfo } from './servers'
8 8
9function listPlugins (parameters: { 9function listPlugins (parameters: {
10 url: string 10 url: string
@@ -216,7 +216,7 @@ function getPluginsCSS (url: string) {
216} 216}
217 217
218function getPackageJSONPath (server: ServerInfo, npmName: string) { 218function getPackageJSONPath (server: ServerInfo, npmName: string) {
219 return join(root(), 'test' + server.internalServerNumber, 'plugins', 'node_modules', npmName, 'package.json') 219 return buildServerDirectory(server, join('plugins', 'node_modules', npmName, 'package.json'))
220} 220}
221 221
222function updatePluginPackageJSON (server: ServerInfo, npmName: string, json: any) { 222function updatePluginPackageJSON (server: ServerInfo, npmName: string, json: any) {
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index 75e79cc41..1126a7d93 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -6,7 +6,7 @@ import { copy, pathExists, readdir, readFile, remove } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { randomInt } from '../../core-utils/miscs/miscs' 7import { randomInt } from '../../core-utils/miscs/miscs'
8import { VideoChannel } from '../../models/videos' 8import { VideoChannel } from '../../models/videos'
9import { getFileSize, root, wait } from '../miscs/miscs' 9import { buildServerDirectory, getFileSize, root, wait } from '../miscs/miscs'
10 10
11interface ServerInfo { 11interface ServerInfo {
12 app: ChildProcess 12 app: ChildProcess
@@ -309,7 +309,7 @@ function cleanupTests (servers: ServerInfo[]) {
309} 309}
310 310
311async function waitUntilLog (server: ServerInfo, str: string, count = 1, strictCount = true) { 311async function waitUntilLog (server: ServerInfo, str: string, count = 1, strictCount = true) {
312 const logfile = join(root(), 'test' + server.internalServerNumber, 'logs/peertube.log') 312 const logfile = buildServerDirectory(server, 'logs/peertube.log')
313 313
314 while (true) { 314 while (true) {
315 const buf = await readFile(logfile) 315 const buf = await readFile(logfile)
@@ -323,7 +323,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1, strictC
323} 323}
324 324
325async function getServerFileSize (server: ServerInfo, subPath: string) { 325async function getServerFileSize (server: ServerInfo, subPath: string) {
326 const path = join(root(), 'test' + server.internalServerNumber, subPath) 326 const path = buildServerDirectory(server, subPath)
327 327
328 return getFileSize(path) 328 return getFileSize(path)
329} 329}
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 4bfcc583e..85c83c5bb 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -53,15 +53,15 @@ function createLive (url: string, token: string, fields: LiveVideoCreate, status
53 }) 53 })
54} 54}
55 55
56async function sendRTMPStreamInVideo (url: string, token: string, videoId: number | string) { 56async function sendRTMPStreamInVideo (url: string, token: string, videoId: number | string, fixtureName?: string) {
57 const res = await getLive(url, token, videoId) 57 const res = await getLive(url, token, videoId)
58 const videoLive = res.body as LiveVideo 58 const videoLive = res.body as LiveVideo
59 59
60 return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey) 60 return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey, fixtureName)
61} 61}
62 62
63function sendRTMPStream (rtmpBaseUrl: string, streamKey: string) { 63function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') {
64 const fixture = buildAbsoluteFixturePath('video_short.mp4') 64 const fixture = buildAbsoluteFixturePath(fixtureName)
65 65
66 const command = ffmpeg(fixture) 66 const command = ffmpeg(fixture)
67 command.inputOption('-stream_loop -1') 67 command.inputOption('-stream_loop -1')
@@ -140,7 +140,7 @@ async function waitUntilLiveStarts (url: string, token: string, videoId: number
140} 140}
141 141
142async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { 142async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
143 const basePath = buildServerDirectory(server.internalServerNumber, 'streaming-playlists') 143 const basePath = buildServerDirectory(server, 'streaming-playlists')
144 const hlsPath = join(basePath, 'hls', videoUUID) 144 const hlsPath = join(basePath, 'hls', videoUUID)
145 145
146 if (resolutions.length === 0) { 146 if (resolutions.length === 0) {
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 29a646541..2b8c55acb 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -9,15 +9,7 @@ import { v4 as uuidv4 } from 'uuid'
9import validator from 'validator' 9import validator from 'validator'
10import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 10import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
11import { VideoDetails, VideoPrivacy } from '../../models/videos' 11import { VideoDetails, VideoPrivacy } from '../../models/videos'
12import { 12import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs'
13 buildAbsoluteFixturePath,
14 buildServerDirectory,
15 dateIsValid,
16 immutableAssign,
17 root,
18 testImage,
19 webtorrentAdd
20} from '../miscs/miscs'
21import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' 13import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
22import { waitJobs } from '../server/jobs' 14import { waitJobs } from '../server/jobs'
23import { ServerInfo } from '../server/servers' 15import { ServerInfo } from '../server/servers'
@@ -335,7 +327,7 @@ async function checkVideoFilesWereRemoved (
335 ] 327 ]
336) { 328) {
337 for (const directory of directories) { 329 for (const directory of directories) {
338 const directoryPath = buildServerDirectory(serverNumber, directory) 330 const directoryPath = buildServerDirectory({ internalServerNumber: serverNumber }, directory)
339 331
340 const directoryExists = await pathExists(directoryPath) 332 const directoryExists = await pathExists(directoryPath)
341 if (directoryExists === false) continue 333 if (directoryExists === false) continue
@@ -489,7 +481,8 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string
489function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { 481function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
490 return new Promise<any>((res, rej) => { 482 return new Promise<any>((res, rej) => {
491 const torrentName = videoUUID + '-' + resolution + '.torrent' 483 const torrentName = videoUUID + '-' + resolution + '.torrent'
492 const torrentPath = join(root(), 'test' + server.internalServerNumber, 'torrents', torrentName) 484 const torrentPath = buildServerDirectory(server, join('torrents', torrentName))
485
493 readFile(torrentPath, (err, data) => { 486 readFile(torrentPath, (err, data) => {
494 if (err) return rej(err) 487 if (err) return rej(err)
495 488