diff options
author | Chocobozzz <me@florianbigard.com> | 2020-09-17 09:20:52 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (patch) | |
tree | 79304b0152b0a38d33b26e65d4acdad0da4032a7 /server/lib/video-transcoding.ts | |
parent | 110d463fece85e87a26aca48a6048ae0017a27b3 (diff) | |
download | PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.gz PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.zst PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.zip |
Live streaming implementation first step
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r-- | server/lib/video-transcoding.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 5a2dbc9f7..a7b73a30d 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -13,13 +13,14 @@ import { copyFile, ensureDir, move, remove, stat } from 'fs-extra' | |||
13 | import { logger } from '../helpers/logger' | 13 | import { logger } from '../helpers/logger' |
14 | import { VideoResolution } from '../../shared/models/videos' | 14 | import { VideoResolution } from '../../shared/models/videos' |
15 | import { VideoFileModel } from '../models/video/video-file' | 15 | import { VideoFileModel } from '../models/video/video-file' |
16 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' | 16 | import { updateMasterHLSPlaylist, updateSha256VODSegments } from './hls' |
17 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 17 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
18 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' | 18 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' |
19 | import { CONFIG } from '../initializers/config' | 19 | import { CONFIG } from '../initializers/config' |
20 | import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models' | 20 | import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models' |
21 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 21 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
22 | import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths' | 22 | import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths' |
23 | import { spawn } from 'child_process' | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * Optimize the original video file and replace it. The resolution is not changed. | 26 | * Optimize the original video file and replace it. The resolution is not changed. |
@@ -182,7 +183,7 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso | |||
182 | const [ videoStreamingPlaylist ] = await VideoStreamingPlaylistModel.upsert({ | 183 | const [ videoStreamingPlaylist ] = await VideoStreamingPlaylistModel.upsert({ |
183 | videoId: video.id, | 184 | videoId: video.id, |
184 | playlistUrl, | 185 | playlistUrl, |
185 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid), | 186 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid, video.isLive), |
186 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), | 187 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), |
187 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | 188 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, |
188 | 189 | ||
@@ -213,7 +214,7 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso | |||
213 | video.setHLSPlaylist(videoStreamingPlaylist) | 214 | video.setHLSPlaylist(videoStreamingPlaylist) |
214 | 215 | ||
215 | await updateMasterHLSPlaylist(video) | 216 | await updateMasterHLSPlaylist(video) |
216 | await updateSha256Segments(video) | 217 | await updateSha256VODSegments(video) |
217 | 218 | ||
218 | return video | 219 | return video |
219 | } | 220 | } |