]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/video-transcoding.ts
Tests for totalRepliesFromVideoAuthor
[github/Chocobozzz/PeerTube.git] / server / lib / video-transcoding.ts
index 9243d17422da17fa46eaa647d03e29886f86771d..4fd1d62a9140f0655d976741ebbcdae83d0919ff 100644 (file)
@@ -81,13 +81,20 @@ async function transcodeNewResolution (video: MVideoWithFile, resolution: VideoR
   const videoOutputPath = getVideoFilePath(video, newVideoFile)
   const videoTranscodedPath = join(transcodeDirectory, getVideoFilename(video, newVideoFile))
 
-  const transcodeOptions = {
-    type: 'video' as 'video',
-    inputPath: videoInputPath,
-    outputPath: videoTranscodedPath,
-    resolution,
-    isPortraitMode: isPortrait
-  }
+  const transcodeOptions = resolution === VideoResolution.H_NOVIDEO
+    ? {
+      type: 'only-audio' as 'only-audio',
+      inputPath: videoInputPath,
+      outputPath: videoTranscodedPath,
+      resolution
+    }
+    : {
+      type: 'video' as 'video',
+      inputPath: videoInputPath,
+      outputPath: videoTranscodedPath,
+      resolution,
+      isPortraitMode: isPortrait
+    }
 
   await transcode(transcodeOptions)
 
@@ -98,7 +105,7 @@ async function mergeAudioVideofile (video: MVideoWithAllFiles, resolution: Video
   const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
   const newExtname = '.mp4'
 
-  const inputVideoFile = video.getMaxQualityFile()
+  const inputVideoFile = video.getMinQualityFile()
 
   const audioInputPath = getVideoFilePath(video, inputVideoFile)
   const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname)
@@ -198,10 +205,8 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso
 
   await createTorrentAndSetInfoHash(videoStreamingPlaylist, newVideoFile)
 
-  const updatedVideoFile = await newVideoFile.save()
-
+  await newVideoFile.save()
   videoStreamingPlaylist.VideoFiles = await videoStreamingPlaylist.$get('VideoFiles') as VideoFileModel[]
-  videoStreamingPlaylist.VideoFiles.push(updatedVideoFile)
 
   video.setHLSPlaylist(videoStreamingPlaylist)