]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/audio-only.ts
Generate random uuid for video files
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / audio-only.ts
index f12d730ccf9fd53f8775c349a26d5f0bcee032e1..7fac6e7389e7e9ef20297f12c33f0b1fd2443eb7 100644 (file)
@@ -1,34 +1,17 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import * as chai from 'chai'
 import 'mocha'
-import {
-  checkDirectoryIsEmpty,
-  checkSegmentHash,
-  checkTmpIsEmpty,
-  cleanupTests,
-  doubleFollow,
-  flushAndRunMultipleServers,
-  getPlaylist,
-  getVideo, makeGetRequest, makeRawRequest,
-  removeVideo, root,
-  ServerInfo,
-  setAccessTokensToServers, updateCustomSubConfig,
-  updateVideo,
-  uploadVideo,
-  waitJobs, webtorrentAdd
-} from '../../../../shared/extra-utils'
-import { VideoDetails } from '../../../../shared/models/videos'
-import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
-import { join } from 'path'
-import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
-import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils'
+import * as chai from 'chai'
+import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
+import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
 
 const expect = chai.expect
 
 describe('Test audio only video transcoding', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let videoUUID: string
+  let webtorrentAudioFileUrl: string
+  let fragmentedAudioFileUrl: string
 
   before(async function () {
     this.timeout(120000)
@@ -43,6 +26,7 @@ describe('Test audio only video transcoding', function () {
           '480p': false,
           '720p': false,
           '1080p': false,
+          '1440p': false,
           '2160p': false
         },
         hls: {
@@ -53,7 +37,7 @@ describe('Test audio only video transcoding', function () {
         }
       }
     }
-    servers = await flushAndRunMultipleServers(2, configOverride)
+    servers = await createMultipleServers(2, configOverride)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -65,15 +49,13 @@ describe('Test audio only video transcoding', function () {
   it('Should upload a video and transcode it', async function () {
     this.timeout(120000)
 
-    const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only' })
-    videoUUID = resUpload.body.video.uuid
+    const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
+    videoUUID = uuid
 
     await waitJobs(servers)
 
     for (const server of servers) {
-      const res = await getVideo(server.url, videoUUID)
-      const video: VideoDetails = res.body
-
+      const video = await server.videos.get({ id: videoUUID })
       expect(video.streamingPlaylists).to.have.lengthOf(1)
 
       for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
@@ -82,19 +64,24 @@ describe('Test audio only video transcoding', function () {
         expect(files[1].resolution.id).to.equal(240)
         expect(files[2].resolution.id).to.equal(0)
       }
+
+      if (server.serverNumber === 1) {
+        webtorrentAudioFileUrl = video.files[2].fileUrl
+        fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
+      }
     }
   })
 
   it('0p transcoded video should not have video', async function () {
     const paths = [
-      join(root(), 'test' + servers[ 0 ].internalServerNumber, 'videos', videoUUID + '-0.mp4'),
-      join(root(), 'test' + servers[ 0 ].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')
+      servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl),
+      servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
     ]
 
     for (const path of paths) {
-      const { audioStream } = await audio.get(path)
-      expect(audioStream[ 'codec_name' ]).to.be.equal('aac')
-      expect(audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
+      const { audioStream } = await getAudioStream(path)
+      expect(audioStream['codec_name']).to.be.equal('aac')
+      expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
 
       const size = await getVideoStreamSize(path)
       expect(size.height).to.equal(0)