diff options
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r-- | server/lib/video-transcoding.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 0fe0ff12a..8e906a1eb 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' | 1 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' | 3 | import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils' |
4 | import { ensureDir, move, remove, stat } from 'fs-extra' | 4 | 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' |
@@ -11,6 +11,9 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla | |||
11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' | 11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' |
12 | import { CONFIG } from '../initializers/config' | 12 | import { CONFIG } from '../initializers/config' |
13 | 13 | ||
14 | /** | ||
15 | * Optimize the original video file and replace it. The resolution is not changed. | ||
16 | */ | ||
14 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { | 17 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { |
15 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 18 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
16 | const newExtname = '.mp4' | 19 | const newExtname = '.mp4' |
@@ -19,10 +22,13 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi | |||
19 | const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) | 22 | const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) |
20 | const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) | 23 | const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) |
21 | 24 | ||
25 | const doQuickTranscode = await(canDoQuickTranscode(videoInputPath)) | ||
26 | |||
22 | const transcodeOptions = { | 27 | const transcodeOptions = { |
23 | inputPath: videoInputPath, | 28 | inputPath: videoInputPath, |
24 | outputPath: videoTranscodedPath, | 29 | outputPath: videoTranscodedPath, |
25 | resolution: inputVideoFile.resolution | 30 | resolution: inputVideoFile.resolution, |
31 | doQuickTranscode | ||
26 | } | 32 | } |
27 | 33 | ||
28 | // Could be very long! | 34 | // Could be very long! |
@@ -52,6 +58,9 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi | |||
52 | } | 58 | } |
53 | } | 59 | } |
54 | 60 | ||
61 | /** | ||
62 | * Transcode the original video file to a lower resolution. | ||
63 | */ | ||
55 | async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { | 64 | async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { |
56 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 65 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
57 | const extname = '.mp4' | 66 | const extname = '.mp4' |