aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-10 14:49:02 +0100
committerChocobozzz <me@florianbigard.com>2020-03-10 16:18:29 +0100
commit7b81edc854902a536083298472bf92bb6726edcf (patch)
tree822dae6b6d4755ac9afffe2569b74dcb45da5535 /server/tests/api/videos
parent8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (diff)
downloadPeerTube-7b81edc854902a536083298472bf92bb6726edcf.tar.gz
PeerTube-7b81edc854902a536083298472bf92bb6726edcf.tar.zst
PeerTube-7b81edc854902a536083298472bf92bb6726edcf.zip
Video file metadata PR cleanup
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-transcoder.ts70
1 files changed, 33 insertions, 37 deletions
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 {
27 root, 27 root,
28 ServerInfo, 28 ServerInfo,
29 setAccessTokensToServers, 29 setAccessTokensToServers,
30 uploadVideo, 30 uploadVideo, uploadVideoAndGetId,
31 waitJobs, 31 waitJobs,
32 webtorrentAdd 32 webtorrentAdd
33} from '../../../../shared/extra-utils' 33} from '../../../../shared/extra-utils'
34import { join } from 'path' 34import { join } from 'path'
35import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 35import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
36import { FfprobeData } from 'fluent-ffmpeg' 36import { FfprobeData } from 'fluent-ffmpeg'
37import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata'
37 38
38const expect = chai.expect 39const expect = chai.expect
39 40
@@ -470,61 +471,56 @@ describe('Test video transcoding', function () {
470 it('Should provide valid ffprobe data', async function () { 471 it('Should provide valid ffprobe data', async function () {
471 this.timeout(160000) 472 this.timeout(160000)
472 473
473 const videoAttributes = { 474 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid
474 name: 'my super name for server 1',
475 description: 'my super description for server 1',
476 fixture: 'video_short.webm'
477 }
478 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
479
480 await waitJobs(servers) 475 await waitJobs(servers)
481 476
482 const res = await getVideosList(servers[1].url) 477 {
478 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4')
479 const metadata = await getMetadataFromFile<VideoFileMetadata>(path)
483 480
484 const videoOnOrigin = res.body.data.find(v => v.name === videoAttributes.name) 481 // expected format properties
485 const res2 = await getVideo(servers[1].url, videoOnOrigin.id) 482 for (const p of [
486 const videoOnOriginDetails: VideoDetails = res2.body 483 'tags.encoder',
484 'format_long_name',
485 'size',
486 'bit_rate'
487 ]) {
488 expect(metadata.format).to.have.nested.property(p)
489 }
487 490
488 { 491 // expected stream properties
489 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoOnOrigin.uuid + '-240.mp4')
490 const metadata = await getMetadataFromFile(path)
491 for (const p of [ 492 for (const p of [
492 // expected format properties 493 'codec_long_name',
493 'format.encoder', 494 'profile',
494 'format.format_long_name', 495 'width',
495 'format.size', 496 'height',
496 'format.bit_rate', 497 'display_aspect_ratio',
497 // expected stream properties 498 'avg_frame_rate',
498 'stream[0].codec_long_name', 499 'pix_fmt'
499 'stream[0].profile',
500 'stream[0].width',
501 'stream[0].height',
502 'stream[0].display_aspect_ratio',
503 'stream[0].avg_frame_rate',
504 'stream[0].pix_fmt'
505 ]) { 500 ]) {
506 expect(metadata).to.have.nested.property(p) 501 expect(metadata.streams[0]).to.have.nested.property(p)
507 } 502 }
503
508 expect(metadata).to.not.have.nested.property('format.filename') 504 expect(metadata).to.not.have.nested.property('format.filename')
509 } 505 }
510 506
511 for (const server of servers) { 507 for (const server of servers) {
512 const res = await getVideosList(server.url) 508 const res2 = await getVideo(server.url, videoUUID)
513 509 const videoDetails: VideoDetails = res2.body
514 const video = res.body.data.find(v => v.name === videoAttributes.name)
515 const res2 = await getVideo(server.url, video.id)
516 const videoDetails = res2.body
517 510
518 const videoFiles = videoDetails.files 511 const videoFiles = videoDetails.files
519 for (const [ index, file ] of videoFiles.entries()) { 512 .concat(videoDetails.streamingPlaylists[0].files)
513 expect(videoFiles).to.have.lengthOf(8)
514
515 for (const file of videoFiles) {
520 expect(file.metadata).to.be.undefined 516 expect(file.metadata).to.be.undefined
517 expect(file.metadataUrl).to.exist
521 expect(file.metadataUrl).to.contain(servers[1].url) 518 expect(file.metadataUrl).to.contain(servers[1].url)
522 expect(file.metadataUrl).to.contain(videoOnOrigin.uuid) 519 expect(file.metadataUrl).to.contain(videoUUID)
523 520
524 const res3 = await getVideoFileMetadataUrl(file.metadataUrl) 521 const res3 = await getVideoFileMetadataUrl(file.metadataUrl)
525 const metadata: FfprobeData = res3.body 522 const metadata: FfprobeData = res3.body
526 expect(metadata).to.have.nested.property('format.size') 523 expect(metadata).to.have.nested.property('format.size')
527 expect(metadata.format.size).to.equal(videoOnOriginDetails.files[index].metadata.format.size)
528 } 524 }
529 } 525 }
530 }) 526 })