diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-20 17:16:55 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 10:07:51 +0100 |
commit | daf6e4801052d3ca6be2fafd20bae2323b1ce175 (patch) | |
tree | a136af611c2543c461ce3fd126ddb7cb1e37a0c2 /server/tests/api/videos/video-transcoder.ts | |
parent | 123f61933611f326ea5a5e8c2ea253ee8720e4f0 (diff) | |
download | PeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.tar.gz PeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.tar.zst PeerTube-daf6e4801052d3ca6be2fafd20bae2323b1ce175.zip |
Split ffmpeg utils with ffprobe utils
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 41 |
1 files changed, 21 insertions, 20 deletions
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 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { FfprobeData } from 'fluent-ffmpeg' | ||
5 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
6 | import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' | 7 | import { join } from 'path' |
7 | import { | 8 | |
8 | audio, | 9 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' |
9 | canDoQuickTranscode, | ||
10 | getVideoFileBitrate, | ||
11 | getVideoFileFPS, | ||
12 | getVideoFileResolution, | ||
13 | getMetadataFromFile | ||
14 | } from '../../../helpers/ffmpeg-utils' | ||
15 | import { | 10 | import { |
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' |
36 | import { join } from 'path' | 32 | import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' |
37 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' | 33 | import { |
38 | import { FfprobeData } from 'fluent-ffmpeg' | 34 | canDoQuickTranscode, |
39 | import { 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 | ||
41 | const expect = chai.expect | 42 | const 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 [ |