aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/videos.ts7
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts12
-rw-r--r--server/lib/live-manager.ts8
-rw-r--r--server/lib/video-paths.ts4
-rw-r--r--server/lib/video-transcoding.ts17
-rw-r--r--server/lib/video.ts2
6 files changed, 31 insertions, 19 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index ab4aac0a1..4053f487c 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -1,10 +1,10 @@
1import { VideoLiveModel } from '@server/models/video/video-live'
2import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
3import { maxBy, minBy } from 'lodash' 2import { maxBy, minBy } from 'lodash'
4import * as magnetUtil from 'magnet-uri' 3import * as magnetUtil from 'magnet-uri'
5import { join } from 'path' 4import { join } from 'path'
6import * as request from 'request' 5import * as request from 'request'
7import * as sequelize from 'sequelize' 6import * as sequelize from 'sequelize'
7import { VideoLiveModel } from '@server/models/video/video-live'
8import { 8import {
9 ActivityHashTagObject, 9 ActivityHashTagObject,
10 ActivityMagnetUrlObject, 10 ActivityMagnetUrlObject,
@@ -13,8 +13,7 @@ import {
13 ActivitypubHttpFetcherPayload, 13 ActivitypubHttpFetcherPayload,
14 ActivityTagObject, 14 ActivityTagObject,
15 ActivityUrlObject, 15 ActivityUrlObject,
16 ActivityVideoUrlObject, 16 ActivityVideoUrlObject
17 VideoState
18} from '../../../shared/index' 17} from '../../../shared/index'
19import { VideoObject } from '../../../shared/models/activitypub/objects' 18import { VideoObject } from '../../../shared/models/activitypub/objects'
20import { VideoPrivacy } from '../../../shared/models/videos' 19import { VideoPrivacy } from '../../../shared/models/videos'
@@ -562,8 +561,6 @@ function isAPHashTagObject (url: any): url is ActivityHashTagObject {
562 return url && url.type === 'Hashtag' 561 return url && url.type === 'Hashtag'
563} 562}
564 563
565
566
567async function createVideo (videoObject: VideoObject, channel: MChannelAccountLight, waitThumbnail = false) { 564async function createVideo (videoObject: VideoObject, channel: MChannelAccountLight, waitThumbnail = false) {
568 logger.debug('Adding remote video %s.', videoObject.id) 565 logger.debug('Adding remote video %s.', videoObject.id)
569 566
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index 3892260c4..3d9341738 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -10,8 +10,9 @@ import { VideoFileModel } from '@server/models/video/video-file'
10import { VideoLiveModel } from '@server/models/video/video-live' 10import { VideoLiveModel } from '@server/models/video/video-live'
11import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' 11import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
12import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' 12import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
13import { VideoLiveEndingPayload, VideoState } from '@shared/models' 13import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
14import { logger } from '../../../helpers/logger' 14import { logger } from '../../../helpers/logger'
15import { generateVideoMiniature } from '@server/lib/thumbnail'
15 16
16async function processVideoLiveEnding (job: Bull.Job) { 17async function processVideoLiveEnding (job: Bull.Job) {
17 const payload = job.data as VideoLiveEndingPayload 18 const payload = job.data as VideoLiveEndingPayload
@@ -109,6 +110,15 @@ async function saveLive (video: MVideo, live: MVideoLive) {
109 await remove(videoInputPath) 110 await remove(videoInputPath)
110 } 111 }
111 112
113 // Regenerate the thumbnail & preview?
114 if (videoWithFiles.getMiniature().automaticallyGenerated === true) {
115 await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.MINIATURE)
116 }
117
118 if (videoWithFiles.getPreview().automaticallyGenerated === true) {
119 await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
120 }
121
112 await publishAndFederateIfNeeded(video, true) 122 await publishAndFederateIfNeeded(video, true)
113} 123}
114 124
diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts
index d253d06fc..9a2914cc5 100644
--- a/server/lib/live-manager.ts
+++ b/server/lib/live-manager.ts
@@ -4,7 +4,13 @@ import * as chokidar from 'chokidar'
4import { FfmpegCommand } from 'fluent-ffmpeg' 4import { FfmpegCommand } from 'fluent-ffmpeg'
5import { ensureDir, stat } from 'fs-extra' 5import { ensureDir, stat } from 'fs-extra'
6import { basename } from 'path' 6import { basename } from 'path'
7import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution, getVideoStreamCodec, getVideoStreamSize, runLiveMuxing, runLiveTranscoding } from '@server/helpers/ffmpeg-utils' 7import {
8 computeResolutionsToTranscode,
9 getVideoFileFPS,
10 getVideoFileResolution,
11 runLiveMuxing,
12 runLiveTranscoding
13} from '@server/helpers/ffmpeg-utils'
8import { logger } from '@server/helpers/logger' 14import { logger } from '@server/helpers/logger'
9import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' 15import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config'
10import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants' 16import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants'
diff --git a/server/lib/video-paths.ts b/server/lib/video-paths.ts
index b6cb39d25..53fc8e81d 100644
--- a/server/lib/video-paths.ts
+++ b/server/lib/video-paths.ts
@@ -9,7 +9,7 @@ import { extractVideo } from '@server/helpers/video'
9function getVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile) { 9function getVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile) {
10 const video = extractVideo(videoOrPlaylist) 10 const video = extractVideo(videoOrPlaylist)
11 11
12 if (isStreamingPlaylist(videoOrPlaylist)) { 12 if (videoFile.isHLS()) {
13 return generateVideoStreamingPlaylistName(video.uuid, videoFile.resolution) 13 return generateVideoStreamingPlaylistName(video.uuid, videoFile.resolution)
14 } 14 }
15 15
@@ -25,7 +25,7 @@ function generateWebTorrentVideoName (uuid: string, resolution: number, extname:
25} 25}
26 26
27function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) { 27function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) {
28 if (isStreamingPlaylist(videoOrPlaylist)) { 28 if (videoFile.isHLS()) {
29 const video = extractVideo(videoOrPlaylist) 29 const video = extractVideo(videoOrPlaylist)
30 30
31 return join(getHLSDirectory(video), getVideoFilename(videoOrPlaylist, videoFile)) 31 return join(getHLSDirectory(video), getVideoFilename(videoOrPlaylist, videoFile))
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index c62b3c1ce..e267b1397 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,5 +1,9 @@
1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' 1import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
2import { basename, extname as extnameUtil, join } from 'path' 2import { basename, extname as extnameUtil, join } from 'path'
3import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
4import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
5import { VideoResolution } from '../../shared/models/videos'
6import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
3import { 7import {
4 canDoQuickTranscode, 8 canDoQuickTranscode,
5 getDurationFromVideoFile, 9 getDurationFromVideoFile,
@@ -9,18 +13,13 @@ import {
9 TranscodeOptions, 13 TranscodeOptions,
10 TranscodeOptionsType 14 TranscodeOptionsType
11} from '../helpers/ffmpeg-utils' 15} from '../helpers/ffmpeg-utils'
12import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
13import { logger } from '../helpers/logger' 16import { logger } from '../helpers/logger'
14import { VideoResolution } from '../../shared/models/videos' 17import { CONFIG } from '../initializers/config'
18import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
15import { VideoFileModel } from '../models/video/video-file' 19import { VideoFileModel } from '../models/video/video-file'
16import { updateMasterHLSPlaylist, updateSha256VODSegments } from './hls'
17import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 20import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
18import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' 21import { updateMasterHLSPlaylist, updateSha256VODSegments } from './hls'
19import { CONFIG } from '../initializers/config'
20import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
21import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
22import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths' 22import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths'
23import { spawn } from 'child_process'
24 23
25/** 24/**
26 * Optimize the original video file and replace it. The resolution is not changed. 25 * Optimize the original video file and replace it. The resolution is not changed.
diff --git a/server/lib/video.ts b/server/lib/video.ts
index 8d9918b2d..d03ab0452 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -4,7 +4,7 @@ import { TagModel } from '@server/models/video/tag'
4import { VideoModel } from '@server/models/video/video' 4import { VideoModel } from '@server/models/video/video'
5import { FilteredModelAttributes } from '@server/types' 5import { FilteredModelAttributes } from '@server/types'
6import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' 6import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
7import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models' 7import { ThumbnailType, VideoCreate, VideoPrivacy } from '@shared/models'
8import { federateVideoIfNeeded } from './activitypub/videos' 8import { federateVideoIfNeeded } from './activitypub/videos'
9import { Notifier } from './notifier' 9import { Notifier } from './notifier'
10import { createVideoMiniatureFromExisting } from './thumbnail' 10import { createVideoMiniatureFromExisting } from './thumbnail'