diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-27 15:57:28 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-27 15:57:43 +0100 |
commit | 056aa7f2b4de1ef128a5fd35527de6dd7a9ebad1 (patch) | |
tree | bf59c7f52be7da2d6bfd7ee18814b9c7f8463966 /server/helpers | |
parent | 6fdc553adb23db216b44e425a85ea76bdf0a2a40 (diff) | |
download | PeerTube-056aa7f2b4de1ef128a5fd35527de6dd7a9ebad1.tar.gz PeerTube-056aa7f2b4de1ef128a5fd35527de6dd7a9ebad1.tar.zst PeerTube-056aa7f2b4de1ef128a5fd35527de6dd7a9ebad1.zip |
Fix resolution for portrait videos
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index b0f95797c..4f75ba5a8 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -6,9 +6,13 @@ import { unlinkPromise } from './core-utils' | |||
6 | import { processImage } from './image-utils' | 6 | import { processImage } from './image-utils' |
7 | import { logger } from './logger' | 7 | import { logger } from './logger' |
8 | 8 | ||
9 | async function getVideoFileHeight (path: string) { | 9 | async function getVideoFileResolution (path: string) { |
10 | const videoStream = await getVideoFileStream(path) | 10 | const videoStream = await getVideoFileStream(path) |
11 | return videoStream.height | 11 | |
12 | return { | ||
13 | videoFileResolution: Math.min(videoStream.height, videoStream.width), | ||
14 | isPortraitMode: videoStream.height > videoStream.width | ||
15 | } | ||
12 | } | 16 | } |
13 | 17 | ||
14 | async function getVideoFileFPS (path: string) { | 18 | async function getVideoFileFPS (path: string) { |
@@ -74,6 +78,7 @@ type TranscodeOptions = { | |||
74 | inputPath: string | 78 | inputPath: string |
75 | outputPath: string | 79 | outputPath: string |
76 | resolution?: VideoResolution | 80 | resolution?: VideoResolution |
81 | isPortraitMode?: boolean | ||
77 | } | 82 | } |
78 | 83 | ||
79 | function transcode (options: TranscodeOptions) { | 84 | function transcode (options: TranscodeOptions) { |
@@ -90,7 +95,8 @@ function transcode (options: TranscodeOptions) { | |||
90 | if (fps > MAX_VIDEO_TRANSCODING_FPS) command = command.withFPS(MAX_VIDEO_TRANSCODING_FPS) | 95 | if (fps > MAX_VIDEO_TRANSCODING_FPS) command = command.withFPS(MAX_VIDEO_TRANSCODING_FPS) |
91 | 96 | ||
92 | if (options.resolution !== undefined) { | 97 | if (options.resolution !== undefined) { |
93 | const size = `?x${options.resolution}` // '?x720' for example | 98 | // '?x720' or '720x?' for example |
99 | const size = options.isPortraitMode === true ? `${options.resolution}x?` : `?x${options.resolution}` | ||
94 | command = command.size(size) | 100 | command = command.size(size) |
95 | } | 101 | } |
96 | 102 | ||
@@ -103,7 +109,7 @@ function transcode (options: TranscodeOptions) { | |||
103 | // --------------------------------------------------------------------------- | 109 | // --------------------------------------------------------------------------- |
104 | 110 | ||
105 | export { | 111 | export { |
106 | getVideoFileHeight, | 112 | getVideoFileResolution, |
107 | getDurationFromVideoFile, | 113 | getDurationFromVideoFile, |
108 | generateImageFromVideoFile, | 114 | generateImageFromVideoFile, |
109 | transcode, | 115 | transcode, |