-import * as Bluebird from 'bluebird'
-import * as chokidar from 'chokidar'
+import { mapSeries } from 'bluebird'
+import { FSWatcher, watch } from 'chokidar'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { appendFile, ensureDir, readFile, stat } from 'fs-extra'
import { basename, join } from 'path'
import { MEMOIZE_TTL, VIDEO_LIVE } from '@server/initializers/constants'
import { VideoFileModel } from '@server/models/video/video-file'
import { MStreamingPlaylistVideo, MUserId, MVideoLiveVideo } from '@server/types/models'
+import { getLiveDirectory } from '../../paths'
import { VideoTranscodingProfilesManager } from '../../transcoding/video-transcoding-profiles'
import { isAbleToUploadVideo } from '../../user'
-import { getHLSDirectory } from '../../video-paths'
import { LiveQuotaStore } from '../live-quota-store'
import { LiveSegmentShaStore } from '../live-segment-sha-store'
import { buildConcatenatedName } from '../live-utils'
private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {}
- private tsWatcher: chokidar.FSWatcher
- private masterWatcher: chokidar.FSWatcher
+ private tsWatcher: FSWatcher
+ private masterWatcher: FSWatcher
private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => {
return isAbleToUploadVideo(userId, 1000)
}
private watchMasterFile (outPath: string) {
- this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
+ this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
- this.masterWatcher.on('add', async () => {
+ this.masterWatcher.on('add', () => {
this.emit('master-playlist-created', { videoId: this.videoId })
this.masterWatcher.close()
private watchTSFiles (outPath: string) {
const startStreamDateTime = new Date().getTime()
- this.tsWatcher = chokidar.watch(outPath + '/*.ts')
+ this.tsWatcher = watch(outPath + '/*.ts')
const playlistIdMatcher = /^([\d+])-/
}
private async prepareDirectories () {
- const outPath = getHLSDirectory(this.videoLive.Video)
+ const outPath = getLiveDirectory(this.videoLive.Video)
await ensureDir(outPath)
const replayDirectory = join(outPath, VIDEO_LIVE.REPLAY_DIRECTORY)
}
private processSegments (hlsVideoPath: string, segmentPaths: string[]) {
- Bluebird.mapSeries(segmentPaths, async previousSegment => {
+ mapSeries(segmentPaths, async previousSegment => {
// Add sha hash of previous segments, because ffmpeg should have finished generating them
await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment)