From 56a4f3fdd824d725e1c5f3128480af177ccc4fcb Mon Sep 17 00:00:00 2001 From: vexorian Date: Tue, 28 Nov 2023 23:03:45 -0400 Subject: [PATCH] Fix 'blocky' playback with mpeg2video. Add preset for libx264, might be unnecessary/wrong --- src/ffmpeg.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 779e379..c503279 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -495,9 +495,17 @@ class FFMPEG extends events.EventEmitter { if ( transcodeVideo && (this.audioOnly !== true) ) { // add the video encoder flags ffmpegArgs.push( + '-crf', '22', `-maxrate:v`, `${this.opts.videoBitrate}k`, `-bufsize:v`, `${this.opts.videoBufSize}k` ); + if (this.opts.videoEncoder.toLowerCase() === "mpeg2video") { + // This makes message "impossible bitrate constraints, this will fail" appear but nothing actually fails and it really looks like b:v is the only way to make the video look good when using mpeg2video + ffmpegArgs.push( + `-qscale:v`, `1`, + '-b:v', `${this.opts.videoBitrate}k` + ); + } } if ( transcodeAudio ) { // add the audio encoder flags