aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-20 17:16:55 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 10:07:51 +0100
commitdaf6e4801052d3ca6be2fafd20bae2323b1ce175 (patch)
treea136af611c2543c461ce3fd126ddb7cb1e37a0c2 /server/tests/api/videos
parent123f61933611f326ea5a5e8c2ea253ee8720e4f0 (diff)
downloadPeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.tar.gz
PeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.tar.zst
PeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.zip
Split ffmpeg utils with ffprobe utils
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/audio-only.ts8
-rw-r--r--server/tests/api/videos/video-transcoder.ts41
2 files changed, 25 insertions, 24 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index ac7a0b89c..053b29ca1 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -1,7 +1,9 @@
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'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { join } from 'path'
6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
5import { 7import {
6 cleanupTests, 8 cleanupTests,
7 doubleFollow, 9 doubleFollow,
@@ -14,8 +16,6 @@ import {
14 waitJobs 16 waitJobs
15} from '../../../../shared/extra-utils' 17} from '../../../../shared/extra-utils'
16import { VideoDetails } from '../../../../shared/models/videos' 18import { VideoDetails } from '../../../../shared/models/videos'
17import { join } from 'path'
18import { audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils'
19 19
20const expect = chai.expect 20const expect = chai.expect
21 21
@@ -85,7 +85,7 @@ describe('Test audio only video transcoding', function () {
85 ] 85 ]
86 86
87 for (const path of paths) { 87 for (const path of paths) {
88 const { audioStream } = await audio.get(path) 88 const { audioStream } = await getAudioStream(path)
89 expect(audioStream['codec_name']).to.be.equal('aac') 89 expect(audioStream['codec_name']).to.be.equal('aac')
90 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) 90 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
91 91
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index ae21c3716..3e336e786 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -1,17 +1,12 @@
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'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { FfprobeData } from 'fluent-ffmpeg'
5import { omit } from 'lodash' 6import { omit } from 'lodash'
6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 7import { join } from 'path'
7import { 8
8 audio, 9import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
9 canDoQuickTranscode,
10 getVideoFileBitrate,
11 getVideoFileFPS,
12 getVideoFileResolution,
13 getMetadataFromFile
14} from '../../../helpers/ffmpeg-utils'
15import { 10import {
16 buildAbsoluteFixturePath, 11 buildAbsoluteFixturePath,
17 cleanupTests, 12 cleanupTests,
@@ -29,14 +24,20 @@ import {
29 ServerInfo, 24 ServerInfo,
30 setAccessTokensToServers, 25 setAccessTokensToServers,
31 updateCustomSubConfig, 26 updateCustomSubConfig,
32 uploadVideo, uploadVideoAndGetId, 27 uploadVideo,
28 uploadVideoAndGetId,
33 waitJobs, 29 waitJobs,
34 webtorrentAdd 30 webtorrentAdd
35} from '../../../../shared/extra-utils' 31} from '../../../../shared/extra-utils'
36import { join } from 'path' 32import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
37import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 33import {
38import { FfprobeData } from 'fluent-ffmpeg' 34 canDoQuickTranscode,
39import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata' 35 getAudioStream,
36 getMetadataFromFile,
37 getVideoFileBitrate,
38 getVideoFileFPS,
39 getVideoFileResolution
40} from '../../../helpers/ffprobe-utils'
40 41
41const expect = chai.expect 42const expect = chai.expect
42 43
@@ -136,7 +137,7 @@ describe('Test video transcoding', function () {
136 expect(videoDetails.files).to.have.lengthOf(4) 137 expect(videoDetails.files).to.have.lengthOf(4)
137 138
138 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 139 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
139 const probe = await audio.get(path) 140 const probe = await getAudioStream(path)
140 141
141 if (probe.audioStream) { 142 if (probe.audioStream) {
142 expect(probe.audioStream['codec_name']).to.be.equal('aac') 143 expect(probe.audioStream['codec_name']).to.be.equal('aac')
@@ -167,7 +168,7 @@ describe('Test video transcoding', function () {
167 168
168 expect(videoDetails.files).to.have.lengthOf(4) 169 expect(videoDetails.files).to.have.lengthOf(4)
169 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 170 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
170 const probe = await audio.get(path) 171 const probe = await getAudioStream(path)
171 expect(probe).to.not.have.property('audioStream') 172 expect(probe).to.not.have.property('audioStream')
172 } 173 }
173 }) 174 })
@@ -192,9 +193,9 @@ describe('Test video transcoding', function () {
192 193
193 expect(videoDetails.files).to.have.lengthOf(4) 194 expect(videoDetails.files).to.have.lengthOf(4)
194 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 195 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
195 const fixtureVideoProbe = await audio.get(fixturePath) 196 const fixtureVideoProbe = await getAudioStream(fixturePath)
196 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 197 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
197 const videoProbe = await audio.get(path) 198 const videoProbe = await getAudioStream(path)
198 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { 199 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
199 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] 200 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
200 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) 201 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
@@ -513,7 +514,7 @@ describe('Test video transcoding', function () {
513 514
514 { 515 {
515 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') 516 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4')
516 const metadata = await getMetadataFromFile<VideoFileMetadata>(path) 517 const metadata = await getMetadataFromFile(path)
517 518
518 // expected format properties 519 // expected format properties
519 for (const p of [ 520 for (const p of [