Fix duplicate HLS resolution in master playlist
authorChocobozzz <me@florianbigard.com>
Tue, 26 Nov 2019 15:36:48 +0000 (16:36 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 26 Nov 2019 15:57:51 +0000 (16:57 +0100)
server/helpers/ffmpeg-utils.ts
server/lib/hls.ts
server/lib/video-transcoding.ts

index 1eea05d1edaaaeeaecc8cce6b8dfaf052c38bd20..00c32e99a7f2d20d6a86ced5f288105a763df527 100644 (file)
@@ -70,7 +70,7 @@ async function getAudioStreamCodec (path: string) {
   if (!audioStream) return ''
 
   const audioCodec = audioStream.codec_name
-  if (audioCodec.codec_name === 'aac') return 'mp4a.40.2'
+  if (audioCodec === 'aac') return 'mp4a.40.2'
 
   logger.warn('Cannot get audio codec of %s.', path, { audioStream })
 
index c94b599df480ce3b282846e8e227ffc290aefe41..443a600887c07d41b533ee733dd72b0c9d51c5dd 100644 (file)
@@ -50,8 +50,8 @@ async function updateMasterHLSPlaylist (video: MVideoWithFile) {
     let line = `#EXT-X-STREAM-INF:${bandwidth},${resolution}`
     if (file.fps) line += ',FRAME-RATE=' + file.fps
 
-    const audioCodec = await getAudioStreamCodec(filePlaylistPath)
-    const videoCodec = await getVideoStreamCodec(filePlaylistPath)
+    const audioCodec = await getAudioStreamCodec(videoFilePath)
+    const videoCodec = await getVideoStreamCodec(videoFilePath)
     line += `,CODECS="${videoCodec},${audioCodec}"`
 
     masterPlaylists.push(line)
index ab5200936595b7ba7b4c41a9a40a7fecb7fbce50..03bc2155991d5af4ecacdd7384afd69f679876ba 100644 (file)
@@ -205,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)