+import * as Bluebird from 'bluebird'
import * as chokidar from 'chokidar'
import { FfmpegCommand } from 'fluent-ffmpeg'
-import { appendFile, copy, ensureDir, readFile, stat } from 'fs-extra'
+import { appendFile, ensureDir, readFile, stat } from 'fs-extra'
import { basename, join } from 'path'
import { isTestInstance } from '@server/helpers/core-utils'
import { getLiveMuxingCommand, getLiveTranscodingCommand } from '@server/helpers/ffmpeg-utils'
import { isAbleToUploadVideo } from './user'
import { getHLSDirectory } from './video-paths'
import { availableEncoders } from './video-transcoding-profiles'
-import * as Bluebird from 'bluebird'
import memoizee = require('memoizee')
logger.info('Running RTMP server on port %d', config.rtmp.port)
this.rtmpServer = new NodeRtmpServer(config)
+ this.rtmpServer.tcpServer.on('error', err => {
+ logger.error('Cannot run RTMP server.', { err })
+ })
+
this.rtmpServer.run()
}
for (let i = 0; i < allResolutions.length; i++) {
const resolution = allResolutions[i]
- VideoFileModel.upsert({
+ const file = new VideoFileModel({
resolution,
size: -1,
extname: '.ts',
infoHash: null,
fps,
videoStreamingPlaylistId: playlist.id
- }).catch(err => {
- logger.error('Cannot create file for live streaming.', { err })
})
+
+ VideoFileModel.customUpsert(file, 'streaming-playlist', null)
+ .catch(err => logger.error('Cannot create file for live streaming.', { err }))
}
const outPath = getHLSDirectory(videoLive.Video)
private isDurationConstraintValid (streamingStartTime: number) {
const maxDuration = CONFIG.LIVE.MAX_DURATION
// No limit
- if (maxDuration === null) return true
+ if (maxDuration < 0) return true
const now = new Date().getTime()
const max = streamingStartTime + maxDuration
await federateVideoIfNeeded(video, false)
+ PeerTubeSocket.Instance.sendVideoViewsUpdate(video)
+
// Only keep not expired watchers
const newWatchers = watchers.filter(w => w > notBefore)
this.watchersPerVideo.set(videoId, newWatchers)