From daf6e4801052d3ca6be2fafd20bae2323b1ce175 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Nov 2020 17:16:55 +0100 Subject: Split ffmpeg utils with ffprobe utils --- server/tests/api/videos/audio-only.ts | 8 +++--- server/tests/api/videos/video-transcoder.ts | 41 +++++++++++++++-------------- server/tests/cli/optimize-old-videos.ts | 6 ++--- 3 files changed, 28 insertions(+), 27 deletions(-) (limited to 'server/tests') 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 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { join } from 'path' +import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' import { cleanupTests, doubleFollow, @@ -14,8 +16,6 @@ import { waitJobs } from '../../../../shared/extra-utils' import { VideoDetails } from '../../../../shared/models/videos' -import { join } from 'path' -import { audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils' const expect = chai.expect @@ -85,7 +85,7 @@ describe('Test audio only video transcoding', function () { ] for (const path of paths) { - const { audioStream } = await audio.get(path) + const { audioStream } = await getAudioStream(path) expect(audioStream['codec_name']).to.be.equal('aac') expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) 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 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { FfprobeData } from 'fluent-ffmpeg' import { omit } from 'lodash' -import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' -import { - audio, - canDoQuickTranscode, - getVideoFileBitrate, - getVideoFileFPS, - getVideoFileResolution, - getMetadataFromFile -} from '../../../helpers/ffmpeg-utils' +import { join } from 'path' + +import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' import { buildAbsoluteFixturePath, cleanupTests, @@ -29,14 +24,20 @@ import { ServerInfo, setAccessTokensToServers, updateCustomSubConfig, - uploadVideo, uploadVideoAndGetId, + uploadVideo, + uploadVideoAndGetId, waitJobs, webtorrentAdd } from '../../../../shared/extra-utils' -import { join } from 'path' -import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' -import { FfprobeData } from 'fluent-ffmpeg' -import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata' +import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' +import { + canDoQuickTranscode, + getAudioStream, + getMetadataFromFile, + getVideoFileBitrate, + getVideoFileFPS, + getVideoFileResolution +} from '../../../helpers/ffprobe-utils' const expect = chai.expect @@ -136,7 +137,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') - const probe = await audio.get(path) + const probe = await getAudioStream(path) if (probe.audioStream) { expect(probe.audioStream['codec_name']).to.be.equal('aac') @@ -167,7 +168,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') - const probe = await audio.get(path) + const probe = await getAudioStream(path) expect(probe).to.not.have.property('audioStream') } }) @@ -192,9 +193,9 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) - const fixtureVideoProbe = await audio.get(fixturePath) + const fixtureVideoProbe = await getAudioStream(fixturePath) const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') - const videoProbe = await audio.get(path) + const videoProbe = await getAudioStream(path) if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) @@ -513,7 +514,7 @@ describe('Test video transcoding', function () { { const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') - const metadata = await getMetadataFromFile(path) + const metadata = await getMetadataFromFile(path) // expected format properties for (const p of [ diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 43f9b7f55..420fb8049 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos' +import { join } from 'path' import { cleanupTests, doubleFollow, @@ -20,9 +20,9 @@ import { wait } from '../../../shared/extra-utils' import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils' +import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos' +import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' -import { join } from 'path' const expect = chai.expect -- cgit v1.2.3