aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-16 08:58:39 +0200
committerChocobozzz <me@florianbigard.com>2019-05-16 08:58:39 +0200
commit1600235a2f4e30c5d4e7d4342d1c299845decc60 (patch)
tree8d170d3133a978526474532fc33ac4ba4878f632 /server/lib/video-transcoding.ts
parentbec4ea343987c69252b84d02f444c0f033d4a3f9 (diff)
parent658a47ab6812586537c3db8a5a003e287c47beb7 (diff)
downloadPeerTube-1600235a2f4e30c5d4e7d4342d1c299845decc60.tar.gz
PeerTube-1600235a2f4e30c5d4e7d4342d1c299845decc60.tar.zst
PeerTube-1600235a2f4e30c5d4e7d4342d1c299845decc60.zip
Merge remote-tracking branch 'origin/pr/1785' into develop
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r--server/lib/video-transcoding.ts13
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 @@
1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' 1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
2import { join } from 'path' 2import { join } from 'path'
3import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils'
4import { ensureDir, move, remove, stat } from 'fs-extra' 4import { ensureDir, move, remove, stat } from 'fs-extra'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { VideoResolution } from '../../shared/models/videos' 6import { VideoResolution } from '../../shared/models/videos'
@@ -11,6 +11,9 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' 11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
12import { CONFIG } from '../initializers/config' 12import { CONFIG } from '../initializers/config'
13 13
14/**
15 * Optimize the original video file and replace it. The resolution is not changed.
16 */
14async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { 17async 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 */
55async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { 64async 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'