diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-01 14:19:44 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-02-01 14:19:44 +0100 |
commit | a2caee9f5162232234de2e8aae6957cc7f38c853 (patch) | |
tree | f6ca87b03ed80ca4b6625a7b2b31706cd4f831ad /server/lib/hls.ts | |
parent | 0f11ec8dd32b50897c18588db948e96cf0fc2c70 (diff) | |
download | PeerTube-a2caee9f5162232234de2e8aae6957cc7f38c853.tar.gz PeerTube-a2caee9f5162232234de2e8aae6957cc7f38c853.tar.zst PeerTube-a2caee9f5162232234de2e8aae6957cc7f38c853.zip |
Fix HLS re transcoding with object storage enabled
Diffstat (limited to 'server/lib/hls.ts')
-rw-r--r-- | server/lib/hls.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index 1574ff27b..985f50587 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -3,6 +3,7 @@ import { flatten, uniq } from 'lodash' | |||
3 | import { basename, dirname, join } from 'path' | 3 | import { basename, dirname, join } from 'path' |
4 | import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models' | 4 | import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models' |
5 | import { sha256 } from '@shared/extra-utils' | 5 | import { sha256 } from '@shared/extra-utils' |
6 | import { VideoStorage } from '@shared/models' | ||
6 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils' | 7 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils' |
7 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
8 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | 9 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' |
@@ -12,6 +13,7 @@ import { P2P_MEDIA_LOADER_PEER_VERSION, REQUEST_TIMEOUTS } from '../initializers | |||
12 | import { sequelizeTypescript } from '../initializers/database' | 13 | import { sequelizeTypescript } from '../initializers/database' |
13 | import { VideoFileModel } from '../models/video/video-file' | 14 | import { VideoFileModel } from '../models/video/video-file' |
14 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 15 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
16 | import { storeHLSFile } from './object-storage' | ||
15 | import { getHlsResolutionPlaylistFilename } from './paths' | 17 | import { getHlsResolutionPlaylistFilename } from './paths' |
16 | import { VideoPathManager } from './video-path-manager' | 18 | import { VideoPathManager } from './video-path-manager' |
17 | 19 | ||
@@ -58,8 +60,12 @@ async function updateMasterHLSPlaylist (video: MVideo, playlist: MStreamingPlayl | |||
58 | }) | 60 | }) |
59 | } | 61 | } |
60 | 62 | ||
61 | await VideoPathManager.Instance.makeAvailablePlaylistFile(playlist, playlist.playlistFilename, masterPlaylistPath => { | 63 | await VideoPathManager.Instance.makeAvailablePlaylistFile(playlist, playlist.playlistFilename, async masterPlaylistPath => { |
62 | return writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n') | 64 | await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n') |
65 | |||
66 | if (playlist.storage === VideoStorage.OBJECT_STORAGE) { | ||
67 | await storeHLSFile(playlist, playlist.playlistFilename, masterPlaylistPath) | ||
68 | } | ||
63 | }) | 69 | }) |
64 | } | 70 | } |
65 | 71 | ||
@@ -94,6 +100,11 @@ async function updateSha256VODSegments (video: MVideoUUID, playlist: MStreamingP | |||
94 | 100 | ||
95 | const outputPath = VideoPathManager.Instance.getFSHLSOutputPath(video, playlist.segmentsSha256Filename) | 101 | const outputPath = VideoPathManager.Instance.getFSHLSOutputPath(video, playlist.segmentsSha256Filename) |
96 | await outputJSON(outputPath, json) | 102 | await outputJSON(outputPath, json) |
103 | |||
104 | if (playlist.storage === VideoStorage.OBJECT_STORAGE) { | ||
105 | await storeHLSFile(playlist, playlist.segmentsSha256Filename) | ||
106 | await remove(outputPath) | ||
107 | } | ||
97 | } | 108 | } |
98 | 109 | ||
99 | async function buildSha256Segment (segmentPath: string) { | 110 | async function buildSha256Segment (segmentPath: string) { |