aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-26 16:25:36 +0100
committerChocobozzz <me@florianbigard.com>2019-11-26 16:25:36 +0100
commit52201311e1973a12960466232d4dec861e8258ee (patch)
tree9203bfec042a3e5d46e67170433b079e31239e8a /server/lib
parent08eb3dca8257ad121ad74b180dc19c75466e221d (diff)
downloadPeerTube-52201311e1973a12960466232d4dec861e8258ee.tar.gz
PeerTube-52201311e1973a12960466232d4dec861e8258ee.tar.zst
PeerTube-52201311e1973a12960466232d4dec861e8258ee.zip
Add codec information in HLS playlist
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/hls.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index 943721dd7..c94b599df 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -1,7 +1,7 @@
1import { basename, dirname, join } from 'path' 1import { basename, dirname, join } from 'path'
2import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers/constants' 2import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers/constants'
3import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' 3import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra'
4import { getVideoFileSize } from '../helpers/ffmpeg-utils' 4import { getVideoStreamSize, getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg-utils'
5import { sha256 } from '../helpers/core-utils' 5import { sha256 } from '../helpers/core-utils'
6import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 6import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
7import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
@@ -42,7 +42,7 @@ async function updateMasterHLSPlaylist (video: MVideoWithFile) {
42 42
43 const videoFilePath = getVideoFilePath(streamingPlaylist, file) 43 const videoFilePath = getVideoFilePath(streamingPlaylist, file)
44 44
45 const size = await getVideoFileSize(videoFilePath) 45 const size = await getVideoStreamSize(videoFilePath)
46 46
47 const bandwidth = 'BANDWIDTH=' + video.getBandwidthBits(file) 47 const bandwidth = 'BANDWIDTH=' + video.getBandwidthBits(file)
48 const resolution = `RESOLUTION=${size.width}x${size.height}` 48 const resolution = `RESOLUTION=${size.width}x${size.height}`
@@ -50,6 +50,10 @@ async function updateMasterHLSPlaylist (video: MVideoWithFile) {
50 let line = `#EXT-X-STREAM-INF:${bandwidth},${resolution}` 50 let line = `#EXT-X-STREAM-INF:${bandwidth},${resolution}`
51 if (file.fps) line += ',FRAME-RATE=' + file.fps 51 if (file.fps) line += ',FRAME-RATE=' + file.fps
52 52
53 const audioCodec = await getAudioStreamCodec(filePlaylistPath)
54 const videoCodec = await getVideoStreamCodec(filePlaylistPath)
55 line += `,CODECS="${videoCodec},${audioCodec}"`
56
53 masterPlaylists.push(line) 57 masterPlaylists.push(line)
54 masterPlaylists.push(VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution)) 58 masterPlaylists.push(VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution))
55 } 59 }