import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
+import { join } from 'path'
+import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
import {
addVideoToBlacklist,
+ buildServerDirectory,
checkLiveCleanup,
checkLiveSegmentHash,
checkResolutionsInMasterPlaylist,
viewVideo,
wait,
waitJobs,
+ waitUntilLivePublished,
waitUntilLiveStarts,
waitUntilLog
} from '../../../../shared/extra-utils'
})
it('Should enable transcoding with some resolutions and correctly save them', async function () {
- this.timeout(60000)
+ this.timeout(120000)
const resolutions = [ 240, 360, 720 ]
+
await updateConf(resolutions)
liveVideoId = await createLiveWrapper(true)
- const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
+ const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, resolutions)
await stopFfmpeg(command)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
+ const bitrateLimits = {
+ 720: 3000 * 1000,
+ 360: 1100 * 1000,
+ 240: 600 * 1000
+ }
+
for (const server of servers) {
const resVideo = await getVideo(server.url, liveVideoId)
const video: VideoDetails = resVideo.body
const file = hlsPlaylist.files.find(f => f.resolution.id === resolution)
expect(file).to.exist
- expect(file.fps).to.be.oneOf([ 24, 25 ])
+ expect(file.fps).to.be.approximately(30, 5)
expect(file.size).to.be.greaterThan(1)
+ const filename = `${video.uuid}-${resolution}-fragmented.mp4`
+ const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename))
+
+ const probe = await ffprobePromise(segmentPath)
+ const videoStream = await getVideoStreamFromFile(segmentPath, probe)
+
+ expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height])
+
await makeRawRequest(file.torrentUrl, 200)
await makeRawRequest(file.fileUrl, 200)
}