import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
-import { join } from 'path'
+import { getMaxBitrate } from '@shared/core-utils'
import {
buildAbsoluteFixturePath,
cleanupTests,
doubleFollow,
generateHighBitrateVideo,
generateVideoWithFramerate,
+ getFileSize,
makeGetRequest,
PeerTubeServer,
setAccessTokensToServers,
waitJobs,
webtorrentAdd
} from '@shared/extra-utils'
-import { getMaxBitrate, HttpStatusCode, VideoResolution, VideoState } from '@shared/models'
-import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
+import { HttpStatusCode, VideoState } from '@shared/models'
import {
canDoQuickTranscode,
getAudioStream,
it('Should accept and transcode additional extensions', async function () {
this.timeout(300_000)
- let tempFixturePath: string
-
- {
- tempFixturePath = await generateHighBitrateVideo()
-
- const bitrate = await getVideoFileBitrate(tempFixturePath)
- expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
- }
-
for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
const attributes = {
name: fixture,
expect(videoDetails.files).to.have.lengthOf(4)
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const file = videoDetails.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const probe = await getAudioStream(path)
if (probe.audioStream) {
const video = data.find(v => v.name === attributes.name)
const videoDetails = await server.videos.get({ id: video.id })
- expect(videoDetails.files).to.have.lengthOf(4)
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const file = videoDetails.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
+
const probe = await getAudioStream(path)
expect(probe).to.not.have.property('audioStream')
}
const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
const fixtureVideoProbe = await getAudioStream(fixturePath)
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+
+ const file = videoDetails.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const videoProbe = await getAudioStream(path)
expect(videoDetails.files[2].fps).to.be.below(31)
expect(videoDetails.files[3].fps).to.be.below(31)
- for (const resolution of [ '240', '360', '480' ]) {
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
+ for (const resolution of [ 240, 360, 480 ]) {
+ const file = videoDetails.files.find(f => f.resolution.id === resolution)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const fps = await getVideoFileFPS(path)
expect(fps).to.be.below(31)
}
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
+ const file = videoDetails.files.find(f => f.resolution.id === 720)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const fps = await getVideoFileFPS(path)
expect(fps).to.be.above(58).and.below(62)
for (const server of servers) {
const { data } = await server.videos.list()
- const video = data.find(v => v.name === attributes.name)
+ const { id } = data.find(v => v.name === attributes.name)
+ const video = await server.videos.get({ id })
{
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const file = video.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(25)
}
{
- const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
+ const file = video.files.find(f => f.resolution.id === 720)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(59)
}
})
describe('Bitrate control', function () {
+
it('Should respect maximum bitrate values', async function () {
this.timeout(160_000)
- let tempFixturePath: string
-
- {
- tempFixturePath = await generateHighBitrateVideo()
-
- const bitrate = await getVideoFileBitrate(tempFixturePath)
- expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
- }
+ const tempFixturePath = await generateHighBitrateVideo()
const attributes = {
name: 'high bitrate video',
for (const server of servers) {
const { data } = await server.videos.list()
- const video = data.find(v => v.name === attributes.name)
+ 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 path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
+ 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 resolution2 = await getVideoFileResolution(path)
+ const dataResolution = await getVideoFileResolution(path)
+
+ expect(resolution).to.equal(resolution)
- expect(resolution2.videoFileResolution.toString()).to.equal(resolution)
- expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS))
+ const maxBitrate = getMaxBitrate({ ...dataResolution, fps })
+ expect(bitrate).to.be.below(maxBitrate)
}
}
})
fixture: 'low-bitrate.mp4'
}
- const { uuid } = await servers[1].videos.upload({ attributes })
+ 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 path = `videos/${uuid}-${r}.mp4`
- const size = await servers[1].servers.getServerFileSize(path)
+ const file = video.files.find(f => f.resolution.id === r)
+
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
+ const size = await getFileSize(path)
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
}
})
await waitJobs(servers)
{
- const path = servers[1].servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
+ const video = await servers[1].videos.get({ id: videoUUID })
+ const file = video.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
const metadata = await getMetadataFromFile(path)
// expected format properties
describe('Transcoding job queue', function () {
it('Should have the appropriate priorities for transcoding jobs', async function () {
- const body = await servers[1].jobs.getJobsList({
+ const body = await servers[1].jobs.list({
start: 0,
count: 100,
sort: '-createdAt',