Created
September 30, 2018 11:18
-
-
Save rigelk/95f676d596debb9b4bbd21819f991afd to your computer and use it in GitHub Desktop.
PeerTube #1135 proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git server/helpers/ffmpeg-utils.ts server/helpers/ffmpeg-utils.ts | |
index ed823a67..92025092 100644 | |
--- server/helpers/ffmpeg-utils.ts | |
+++ server/helpers/ffmpeg-utils.ts | |
@@ -116,10 +116,6 @@ type TranscodeOptions = { | |
function transcode (options: TranscodeOptions) { | |
return new Promise<void>(async (res, rej) => { | |
- if (options.resolution === undefined) { | |
- return rej('Invalid video file') | |
- } | |
- | |
let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING }) | |
.output(options.outputPath) | |
.preset(standard) | |
@@ -130,16 +126,18 @@ function transcode (options: TranscodeOptions) { | |
} | |
let fps = await getVideoFileFPS(options.inputPath) | |
- // '?x720' or '720x?' for example | |
- const size = options.isPortraitMode === true ? `${options.resolution}x?` : `?x${options.resolution}` | |
- command = command.size(size) | |
- | |
- // On small/medium resolutions, limit FPS | |
- if ( | |
- options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && | |
- fps > VIDEO_TRANSCODING_FPS.AVERAGE | |
- ) { | |
- fps = VIDEO_TRANSCODING_FPS.AVERAGE | |
+ if (options.resolution !== undefined) { | |
+ // '?x720' or '720x?' for example | |
+ const size = options.isPortraitMode === true ? `${options.resolution}x?` : `?x${options.resolution}` | |
+ command = command.size(size) | |
+ | |
+ // On small/medium resolutions, limit FPS | |
+ if ( | |
+ options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && | |
+ fps > VIDEO_TRANSCODING_FPS.AVERAGE | |
+ ) { | |
+ fps = VIDEO_TRANSCODING_FPS.AVERAGE | |
+ } | |
} | |
if (fps) { | |
diff --git shared/models/videos/video-resolution.enum.ts shared/models/videos/video-resolution.enum.ts | |
index d608a7bc..63771e99 100644 | |
--- shared/models/videos/video-resolution.enum.ts | |
+++ shared/models/videos/video-resolution.enum.ts | |
@@ -38,6 +38,7 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number) { | |
return 1750 * 1000 | |
} | |
case VideoResolution.H_1080P: | |
+ default: | |
if (fps === 60) { | |
// quality according to Google Live Encoder: 3000 - 6000 Kbps | |
// Quality according to YouTube Video Info: 4387 Kbps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment