From 7b81edc854902a536083298472bf92bb6726edcf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Mar 2020 14:49:02 +0100 Subject: Video file metadata PR cleanup --- server/tests/api/videos/video-transcoder.ts | 70 ++++++++++++++--------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index ce0dd14d5..13b3530b1 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -27,13 +27,14 @@ import { root, ServerInfo, setAccessTokensToServers, - uploadVideo, + 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' const expect = chai.expect @@ -470,61 +471,56 @@ describe('Test video transcoding', function () { it('Should provide valid ffprobe data', async function () { this.timeout(160000) - const videoAttributes = { - name: 'my super name for server 1', - description: 'my super description for server 1', - fixture: 'video_short.webm' - } - await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) - + const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid await waitJobs(servers) - const res = await getVideosList(servers[1].url) + { + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') + const metadata = await getMetadataFromFile(path) - const videoOnOrigin = res.body.data.find(v => v.name === videoAttributes.name) - const res2 = await getVideo(servers[1].url, videoOnOrigin.id) - const videoOnOriginDetails: VideoDetails = res2.body + // expected format properties + for (const p of [ + 'tags.encoder', + 'format_long_name', + 'size', + 'bit_rate' + ]) { + expect(metadata.format).to.have.nested.property(p) + } - { - const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoOnOrigin.uuid + '-240.mp4') - const metadata = await getMetadataFromFile(path) + // expected stream properties for (const p of [ - // expected format properties - 'format.encoder', - 'format.format_long_name', - 'format.size', - 'format.bit_rate', - // expected stream properties - 'stream[0].codec_long_name', - 'stream[0].profile', - 'stream[0].width', - 'stream[0].height', - 'stream[0].display_aspect_ratio', - 'stream[0].avg_frame_rate', - 'stream[0].pix_fmt' + 'codec_long_name', + 'profile', + 'width', + 'height', + 'display_aspect_ratio', + 'avg_frame_rate', + 'pix_fmt' ]) { - expect(metadata).to.have.nested.property(p) + expect(metadata.streams[0]).to.have.nested.property(p) } + expect(metadata).to.not.have.nested.property('format.filename') } for (const server of servers) { - const res = await getVideosList(server.url) - - const video = res.body.data.find(v => v.name === videoAttributes.name) - const res2 = await getVideo(server.url, video.id) - const videoDetails = res2.body + const res2 = await getVideo(server.url, videoUUID) + const videoDetails: VideoDetails = res2.body const videoFiles = videoDetails.files - for (const [ index, file ] of videoFiles.entries()) { + .concat(videoDetails.streamingPlaylists[0].files) + expect(videoFiles).to.have.lengthOf(8) + + for (const file of videoFiles) { expect(file.metadata).to.be.undefined + expect(file.metadataUrl).to.exist expect(file.metadataUrl).to.contain(servers[1].url) - expect(file.metadataUrl).to.contain(videoOnOrigin.uuid) + expect(file.metadataUrl).to.contain(videoUUID) const res3 = await getVideoFileMetadataUrl(file.metadataUrl) const metadata: FfprobeData = res3.body expect(metadata).to.have.nested.property('format.size') - expect(metadata.format.size).to.equal(videoOnOriginDetails.files[index].metadata.format.size) } } }) -- cgit v1.2.3