diff options
author | Chocobozzz <me@florianbigard.com> | 2023-04-21 14:55:10 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-05-09 08:57:34 +0200 |
commit | 0c9668f77901e7540e2c7045eb0f2974a4842a69 (patch) | |
tree | 226d3dd1565b0bb56588897af3b8530e6216e96b /server/lib/hls.ts | |
parent | 6bcb854cdea8688a32240bc5719c7d139806e00b (diff) | |
download | PeerTube-0c9668f77901e7540e2c7045eb0f2974a4842a69.tar.gz PeerTube-0c9668f77901e7540e2c7045eb0f2974a4842a69.tar.zst PeerTube-0c9668f77901e7540e2c7045eb0f2974a4842a69.zip |
Implement remote runner jobs in server
Move ffmpeg functions to @shared
Diffstat (limited to 'server/lib/hls.ts')
-rw-r--r-- | server/lib/hls.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index 053b5d326..fc1d7e1b0 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -3,10 +3,11 @@ import { flatten } from 'lodash' | |||
3 | import PQueue from 'p-queue' | 3 | import PQueue from 'p-queue' |
4 | import { basename, dirname, join } from 'path' | 4 | import { basename, dirname, join } from 'path' |
5 | import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' | 5 | import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models' |
6 | import { uniqify } from '@shared/core-utils' | 6 | import { uniqify, uuidRegex } from '@shared/core-utils' |
7 | import { sha256 } from '@shared/extra-utils' | 7 | import { sha256 } from '@shared/extra-utils' |
8 | import { getVideoStreamDimensionsInfo } from '@shared/ffmpeg' | ||
8 | import { VideoStorage } from '@shared/models' | 9 | import { VideoStorage } from '@shared/models' |
9 | import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamDimensionsInfo } from '../helpers/ffmpeg' | 10 | import { getAudioStreamCodec, getVideoStreamCodec } from '../helpers/ffmpeg' |
10 | import { logger } from '../helpers/logger' | 11 | import { logger } from '../helpers/logger' |
11 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | 12 | import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' |
12 | import { generateRandomString } from '../helpers/utils' | 13 | import { generateRandomString } from '../helpers/utils' |
@@ -234,6 +235,16 @@ function downloadPlaylistSegments (playlistUrl: string, destinationDir: string, | |||
234 | 235 | ||
235 | // --------------------------------------------------------------------------- | 236 | // --------------------------------------------------------------------------- |
236 | 237 | ||
238 | async function renameVideoFileInPlaylist (playlistPath: string, newVideoFilename: string) { | ||
239 | const content = await readFile(playlistPath, 'utf8') | ||
240 | |||
241 | const newContent = content.replace(new RegExp(`${uuidRegex}-\\d+-fragmented.mp4`, 'g'), newVideoFilename) | ||
242 | |||
243 | await writeFile(playlistPath, newContent, 'utf8') | ||
244 | } | ||
245 | |||
246 | // --------------------------------------------------------------------------- | ||
247 | |||
237 | function injectQueryToPlaylistUrls (content: string, queryString: string) { | 248 | function injectQueryToPlaylistUrls (content: string, queryString: string) { |
238 | return content.replace(/\.(m3u8|ts|mp4)/gm, '.$1?' + queryString) | 249 | return content.replace(/\.(m3u8|ts|mp4)/gm, '.$1?' + queryString) |
239 | } | 250 | } |
@@ -247,7 +258,8 @@ export { | |||
247 | downloadPlaylistSegments, | 258 | downloadPlaylistSegments, |
248 | updateStreamingPlaylistsInfohashesIfNeeded, | 259 | updateStreamingPlaylistsInfohashesIfNeeded, |
249 | updatePlaylistAfterFileChange, | 260 | updatePlaylistAfterFileChange, |
250 | injectQueryToPlaylistUrls | 261 | injectQueryToPlaylistUrls, |
262 | renameVideoFileInPlaylist | ||
251 | } | 263 | } |
252 | 264 | ||
253 | // --------------------------------------------------------------------------- | 265 | // --------------------------------------------------------------------------- |