diff options
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r-- | server/lib/video-transcoding.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index ba6b29163..a204c0c63 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -5,16 +5,16 @@ import { ensureDir, move, remove, stat } from 'fs-extra' | |||
5 | import { logger } from '../helpers/logger' | 5 | import { logger } from '../helpers/logger' |
6 | import { VideoResolution } from '../../shared/models/videos' | 6 | import { VideoResolution } from '../../shared/models/videos' |
7 | import { VideoFileModel } from '../models/video/video-file' | 7 | import { VideoFileModel } from '../models/video/video-file' |
8 | import { VideoModel } from '../models/video/video' | ||
9 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' | 8 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' |
10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 9 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' | 10 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' |
12 | import { CONFIG } from '../initializers/config' | 11 | import { CONFIG } from '../initializers/config' |
12 | import { MVideoFile, MVideoWithFile, MVideoWithFileThumbnail } from '@server/typings/models' | ||
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Optimize the original video file and replace it. The resolution is not changed. | 15 | * Optimize the original video file and replace it. The resolution is not changed. |
16 | */ | 16 | */ |
17 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { | 17 | async function optimizeVideofile (video: MVideoWithFile, inputVideoFileArg?: MVideoFile) { |
18 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 18 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
19 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR | 19 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR |
20 | const newExtname = '.mp4' | 20 | const newExtname = '.mp4' |
@@ -57,7 +57,7 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi | |||
57 | /** | 57 | /** |
58 | * Transcode the original video file to a lower resolution. | 58 | * Transcode the original video file to a lower resolution. |
59 | */ | 59 | */ |
60 | async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { | 60 | async function transcodeOriginalVideofile (video: MVideoWithFile, resolution: VideoResolution, isPortrait: boolean) { |
61 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 61 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
62 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR | 62 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR |
63 | const extname = '.mp4' | 63 | const extname = '.mp4' |
@@ -87,7 +87,7 @@ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoR | |||
87 | return onVideoFileTranscoding(video, newVideoFile, videoTranscodedPath, videoOutputPath) | 87 | return onVideoFileTranscoding(video, newVideoFile, videoTranscodedPath, videoOutputPath) |
88 | } | 88 | } |
89 | 89 | ||
90 | async function mergeAudioVideofile (video: VideoModel, resolution: VideoResolution) { | 90 | async function mergeAudioVideofile (video: MVideoWithFileThumbnail, resolution: VideoResolution) { |
91 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 91 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
92 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR | 92 | const transcodeDirectory = CONFIG.STORAGE.TMP_DIR |
93 | const newExtname = '.mp4' | 93 | const newExtname = '.mp4' |
@@ -117,7 +117,7 @@ async function mergeAudioVideofile (video: VideoModel, resolution: VideoResoluti | |||
117 | return onVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) | 117 | return onVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) |
118 | } | 118 | } |
119 | 119 | ||
120 | async function generateHlsPlaylist (video: VideoModel, resolution: VideoResolution, isPortraitMode: boolean) { | 120 | async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoResolution, isPortraitMode: boolean) { |
121 | const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) | 121 | const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) |
122 | await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)) | 122 | await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)) |
123 | 123 | ||
@@ -165,14 +165,14 @@ export { | |||
165 | 165 | ||
166 | // --------------------------------------------------------------------------- | 166 | // --------------------------------------------------------------------------- |
167 | 167 | ||
168 | async function onVideoFileTranscoding (video: VideoModel, videoFile: VideoFileModel, transcodingPath: string, outputPath: string) { | 168 | async function onVideoFileTranscoding (video: MVideoWithFile, videoFile: MVideoFile, transcodingPath: string, outputPath: string) { |
169 | const stats = await stat(transcodingPath) | 169 | const stats = await stat(transcodingPath) |
170 | const fps = await getVideoFileFPS(transcodingPath) | 170 | const fps = await getVideoFileFPS(transcodingPath) |
171 | 171 | ||
172 | await move(transcodingPath, outputPath) | 172 | await move(transcodingPath, outputPath) |
173 | 173 | ||
174 | videoFile.set('size', stats.size) | 174 | videoFile.size = stats.size |
175 | videoFile.set('fps', fps) | 175 | videoFile.fps = fps |
176 | 176 | ||
177 | await video.createTorrentAndSetInfoHash(videoFile) | 177 | await video.createTorrentAndSetInfoHash(videoFile) |
178 | 178 | ||