aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-03-10 14:39:40 +0100
committerGitHub <noreply@github.com>2020-03-10 14:39:40 +0100
commit8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (patch)
tree1f87041b2cd76222844960602cdc9f52fe206c7b /server/tests/api/videos/video-transcoder.ts
parentedb868655e52f934a71141175cf9dc6cb4753e11 (diff)
downloadPeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.gz
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.zst
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.zip
Add video file metadata to download modal, via ffprobe (#2411)
* Add video file metadata via ffprobe * Federate video file metadata * Add tests for file metadata generation * Complete tests for videoFile metadata federation * Lint migration and video-file for metadata * Objectify metadata from getter in ffmpeg-utils * Add metadataUrl to all videoFiles * Simplify metadata API middleware * Load playlist in videoFile when requesting metadata
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts73
1 files changed, 72 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 3e73ccbfa..ce0dd14d5 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,7 +4,14 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
7import { audio, canDoQuickTranscode, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 7import {
8 audio,
9 canDoQuickTranscode,
10 getVideoFileBitrate,
11 getVideoFileFPS,
12 getVideoFileResolution,
13 getMetadataFromFile
14} from '../../../helpers/ffmpeg-utils'
8import { 15import {
9 buildAbsoluteFixturePath, 16 buildAbsoluteFixturePath,
10 cleanupTests, 17 cleanupTests,
@@ -14,6 +21,7 @@ import {
14 generateVideoWithFramerate, 21 generateVideoWithFramerate,
15 getMyVideos, 22 getMyVideos,
16 getVideo, 23 getVideo,
24 getVideoFileMetadataUrl,
17 getVideosList, 25 getVideosList,
18 makeGetRequest, 26 makeGetRequest,
19 root, 27 root,
@@ -25,6 +33,7 @@ import {
25} from '../../../../shared/extra-utils' 33} from '../../../../shared/extra-utils'
26import { join } from 'path' 34import { join } from 'path'
27import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 35import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
36import { FfprobeData } from 'fluent-ffmpeg'
28 37
29const expect = chai.expect 38const expect = chai.expect
30 39
@@ -458,6 +467,68 @@ describe('Test video transcoding', function () {
458 } 467 }
459 }) 468 })
460 469
470 it('Should provide valid ffprobe data', async function () {
471 this.timeout(160000)
472
473 const videoAttributes = {
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)
481
482 const res = await getVideosList(servers[1].url)
483
484 const videoOnOrigin = res.body.data.find(v => v.name === videoAttributes.name)
485 const res2 = await getVideo(servers[1].url, videoOnOrigin.id)
486 const videoOnOriginDetails: VideoDetails = res2.body
487
488 {
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 // expected format properties
493 'format.encoder',
494 'format.format_long_name',
495 'format.size',
496 'format.bit_rate',
497 // expected stream properties
498 'stream[0].codec_long_name',
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 ]) {
506 expect(metadata).to.have.nested.property(p)
507 }
508 expect(metadata).to.not.have.nested.property('format.filename')
509 }
510
511 for (const server of servers) {
512 const res = await getVideosList(server.url)
513
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
518 const videoFiles = videoDetails.files
519 for (const [ index, file ] of videoFiles.entries()) {
520 expect(file.metadata).to.be.undefined
521 expect(file.metadataUrl).to.contain(servers[1].url)
522 expect(file.metadataUrl).to.contain(videoOnOrigin.uuid)
523
524 const res3 = await getVideoFileMetadataUrl(file.metadataUrl)
525 const metadata: FfprobeData = res3.body
526 expect(metadata).to.have.nested.property('format.size')
527 expect(metadata.format.size).to.equal(videoOnOriginDetails.files[index].metadata.format.size)
528 }
529 }
530 })
531
461 after(async function () { 532 after(async function () {
462 await cleanupTests(servers) 533 await cleanupTests(servers)
463 }) 534 })