diff options
-rw-r--r-- | server/lib/hls.ts | 8 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 |
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' | |||
8 | import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg' | 8 | import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg' |
9 | import { VideoStorage } from '@shared/models' | 9 | import { VideoStorage } from '@shared/models' |
10 | import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg' | 10 | import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg' |
11 | import { logger } from '../helpers/logger' | 11 | import { logger, loggerTagsFactory } from '../helpers/logger' |
12 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | 12 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' |
13 | import { generateRandomString } from '../helpers/utils' | 13 | import { generateRandomString } from '../helpers/utils' |
14 | import { CONFIG } from '../initializers/config' | 14 | import { CONFIG } from '../initializers/config' |
@@ -20,6 +20,8 @@ import { storeHLSFileFromFilename } from './object-storage' | |||
20 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths' | 20 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHlsResolutionPlaylistFilename } from './paths' |
21 | import { VideoPathManager } from './video-path-manager' | 21 | import { VideoPathManager } from './video-path-manager' |
22 | 22 | ||
23 | const lTags = loggerTagsFactory('hls') | ||
24 | |||
23 | async function updateStreamingPlaylistsInfohashesIfNeeded () { | 25 | async 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 | } |