aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/hls.ts8
-rw-r--r--server/models/video/video.ts2
2 files changed, 7 insertions, 3 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index fc1d7e1b0..19044d7c2 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -8,7 +8,7 @@ import { sha256 } from '@shared/extra-utils'
8import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg' 8import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg'
9import { VideoStorage } from '@shared/models' 9import { VideoStorage } from '@shared/models'
10import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg' 10import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg'
11import { logger } from '../helpers/logger' 11import { logger, loggerTagsFactory } from '../helpers/logger'
12import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' 12import { doRequest, doRequestAndSaveToFile } from '../helpers/requests'
13import { generateRandomString } from '../helpers/utils' 13import { generateRandomString } from '../helpers/utils'
14import { CONFIG } from '../initializers/config' 14import { CONFIG } from '../initializers/config'
@@ -20,6 +20,8 @@ import { storeHLSFileFromFilename } from './object-storage'
20import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths' 20import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths'
21import { VideoPathManager } from './video-path-manager' 21import { VideoPathManager } from './video-path-manager'
22 22
23const lTags = loggerTagsFactory('hls')
24
23async function updateStreamingPlaylistsInfohashesIfNeeded () { 25async function updateStreamingPlaylistsInfohashesIfNeeded () {
24 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() 26 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion()
25 27
@@ -48,7 +50,7 @@ async function updatePlaylistAfterFileChange (video: MVideo, playlist: MStreamin
48 50
49 video.setHLSPlaylist(playlistWithFiles) 51 video.setHLSPlaylist(playlistWithFiles)
50 } catch (err) { 52 } catch (err) {
51 logger.info('Cannot update playlist after file change. Maybe due to concurrent transcoding', { err }) 53 logger.warn('Cannot update playlist after file change. Maybe due to concurrent transcoding', { err })
52 } 54 }
53} 55}
54 56
@@ -95,6 +97,8 @@ function updateMasterHLSPlaylist (video: MVideo, playlistArg: MStreamingPlaylist
95 const masterPlaylistPath = VideoPathManager.Instance.getFSHLSOutputPath(video, playlist.playlistFilename) 97 const masterPlaylistPath = VideoPathManager.Instance.getFSHLSOutputPath(video, playlist.playlistFilename)
96 await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n') 98 await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n')
97 99
100 logger.info('Updating %s master playlist file of video %s', masterPlaylistPath, video.uuid, lTags(video.uuid))
101
98 if (playlist.storage === VideoStorage.OBJECT_STORAGE) { 102 if (playlist.storage === VideoStorage.OBJECT_STORAGE) {
99 playlist.playlistUrl = await storeHLSFileFromFilename(playlist, playlist.playlistFilename) 103 playlist.playlistUrl = await storeHLSFileFromFilename(playlist, playlist.playlistFilename)
100 await remove(masterPlaylistPath) 104 await remove(masterPlaylistPath)
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 06aec1308..3a0d95b62 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -2016,7 +2016,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
2016 } 2016 }
2017 2017
2018 getBandwidthBits (this: MVideo, videoFile: MVideoFile) { 2018 getBandwidthBits (this: MVideo, videoFile: MVideoFile) {
2019 if (!this.duration) throw new Error(`Cannot get bandwidth bits because video ${this.url} has duration of 0`) 2019 if (!this.duration) return videoFile.size
2020 2020
2021 return Math.ceil((videoFile.size * 8) / this.duration) 2021 return Math.ceil((videoFile.size * 8) / this.duration)
2022 } 2022 }