From 5ba49f268deb76b168559fe5fe2506b0bd5af9a8 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 24 Apr 2019 20:27:05 +0200 Subject: Dont transcode videos when it is not required (fixes #1780) --- server/lib/video-transcoding.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'server/lib') diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 0fe0ff12a..05afb44d1 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -1,6 +1,6 @@ -import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' +import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER, VIDEO_TRANSCODING_FPS } from '../initializers/constants' import { join } from 'path' -import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' +import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils' import { ensureDir, move, remove, stat } from 'fs-extra' import { logger } from '../helpers/logger' import { VideoResolution } from '../../shared/models/videos' @@ -19,10 +19,13 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) + const doQuickTranscode = await(canDoQuickTranscode(videoInputPath)) + const transcodeOptions = { inputPath: videoInputPath, outputPath: videoTranscodedPath, - resolution: inputVideoFile.resolution + resolution: inputVideoFile.resolution, + doQuickTranscode } // Could be very long! -- cgit v1.2.3 From 7ed2c1a46fd11caca16d5aec80d9f90d7a2d3429 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 4 May 2019 03:18:32 +0200 Subject: fixed formatting, added test case --- server/lib/video-transcoding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/lib') diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 05afb44d1..81aa7a4c4 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -1,4 +1,4 @@ -import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER, VIDEO_TRANSCODING_FPS } from '../initializers/constants' +import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' import { join } from 'path' import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils' import { ensureDir, move, remove, stat } from 'fs-extra' -- cgit v1.2.3 From 658a47ab6812586537c3db8a5a003e287c47beb7 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 13 May 2019 13:02:42 +0200 Subject: Added comments for transcode functions --- server/lib/video-transcoding.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'server/lib') diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 81aa7a4c4..8e906a1eb 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -11,6 +11,9 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' import { CONFIG } from '../initializers/config' +/** + * Optimize the original video file and replace it. The resolution is not changed. + */ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR const newExtname = '.mp4' @@ -55,6 +58,9 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi } } +/** + * Transcode the original video file to a lower resolution. + */ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR const extname = '.mp4' -- cgit v1.2.3