Brion VIBBER has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/389900 )
Change subject: Use constrained quality mode for WebM VP8 and VP9 ...................................................................... Use constrained quality mode for WebM VP8 and VP9 Use -crf option for both VP8 and VP9, which uses lower bitrate when possible while maintaining a certain quality level. This tends to use full bitrate for complex videos and lower bitrates for simpler videos with less motion. Replaces the VBR setting last introduced for VP9. * added 'crf' setting * removed the 'vbr' setting previously used for VP9 * tweaked the max size for 2160p VP8 to match VP9. * removed minimum keyframe interval forcing * increased max keyframe interval from 128 to 240 Bug: T70418 Change-Id: Ic48293c9666fc579f9a876a75266acadea326980 --- M WebVideoTranscode/WebVideoTranscode.php M WebVideoTranscode/WebVideoTranscodeJob.php 2 files changed, 38 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/00/389900/1 diff --git a/WebVideoTranscode/WebVideoTranscode.php b/WebVideoTranscode/WebVideoTranscode.php index 71f6460..8e21edd 100644 --- a/WebVideoTranscode/WebVideoTranscode.php +++ b/WebVideoTranscode/WebVideoTranscode.php @@ -175,10 +175,10 @@ [ 'maxSize' => '288x160', 'videoBitrate' => '128', + 'crf' => '10', 'audioQuality' => '-1', - 'noUpscaling' => 'true', 'twopass' => 'true', - 'keyframeInterval' => '128', + 'keyframeInterval' => '240', 'bufDelay' => '256', 'videoCodec' => 'vp8', 'slices' => '2', @@ -188,10 +188,10 @@ [ 'maxSize' => '426x240', 'videoBitrate' => '256', + 'crf' => '10', 'audioQuality' => '1', - 'noUpscaling' => 'true', 'twopass' => 'true', - 'keyframeInterval' => '128', + 'keyframeInterval' => '240', 'bufDelay' => '256', 'videoCodec' => 'vp8', 'slices' => '2', @@ -201,10 +201,10 @@ [ 'maxSize' => '640x360', 'videoBitrate' => '512', + 'crf' => '10', 'audioQuality' => '1', - 'noUpscaling' => 'true', 'twopass' => 'true', - 'keyframeInterval' => '128', + 'keyframeInterval' => '240', 'bufDelay' => '256', 'videoCodec' => 'vp8', 'slices' => '2', @@ -214,10 +214,10 @@ [ 'maxSize' => '854x480', 'videoBitrate' => '1024', + 'crf' => '10', 'audioQuality' => '2', - 'noUpscaling' => 'true', 'twopass' => 'true', - 'keyframeInterval' => '128', + 'keyframeInterval' => '240', 'bufDelay' => '256', 'videoCodec' => 'vp8', 'slices' => '4', @@ -227,40 +227,52 @@ [ 'maxSize' => '1280x720', 'videoBitrate' => '2048', + 'crf' => '10', 'audioQuality' => 3, - 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '240', 'videoCodec' => 'vp8', 'slices' => '4', + 'speed' => '1', 'type' => 'video/webm; codecs="vp8, vorbis"', ], self::ENC_WEBM_1080P => [ 'maxSize' => '1920x1080', 'videoBitrate' => '4096', + 'crf' => '10', 'audioQuality' => 3, - 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '240', 'videoCodec' => 'vp8', 'slices' => '4', + 'speed' => '1', 'type' => 'video/webm; codecs="vp8, vorbis"', ], self::ENC_WEBM_1440P => [ 'maxSize' => '2560x1440', 'videoBitrate' => '8192', + 'crf' => '10', 'audioQuality' => 3, - 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '240', 'videoCodec' => 'vp8', 'slices' => '8', + 'speed' => '2', 'type' => 'video/webm; codecs="vp8, vorbis"', ], self::ENC_WEBM_2160P => [ - 'maxSize' => '4096x2160', + 'maxSize' => '3840x2160', 'videoBitrate' => '16384', + 'crf' => '10', 'audioQuality' => 3, - 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '240', 'videoCodec' => 'vp8', 'slices' => '8', + 'speed' => '2', 'type' => 'video/webm; codecs="vp8, vorbis"', ], @@ -269,8 +281,7 @@ [ 'maxSize' => '288x160', 'videoBitrate' => '80', - // min bitrate, max bitrate, buffer size ratios - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '37', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -285,7 +296,7 @@ [ 'maxSize' => '426x240', 'videoBitrate' => '150', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '37', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -300,7 +311,7 @@ [ 'maxSize' => '640x360', 'videoBitrate' => '320', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '36', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -316,7 +327,7 @@ [ 'maxSize' => '854x480', 'videoBitrate' => '640', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '33', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -332,7 +343,7 @@ [ 'maxSize' => '1280x720', 'videoBitrate' => '1280', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '32', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -348,7 +359,7 @@ [ 'maxSize' => '1920x1080', 'videoBitrate' => '2560', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '31', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -364,7 +375,7 @@ [ 'maxSize' => '2560x1440', 'videoBitrate' => '5120', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '24', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', @@ -380,7 +391,7 @@ [ 'maxSize' => '3840x2160', 'videoBitrate' => '10240', - 'vbr' => [ 0.5, 1.5, 10 ], + 'crf' => '15', 'samplerate' => '48000', 'twopass' => 'true', 'altref' => 'true', diff --git a/WebVideoTranscode/WebVideoTranscodeJob.php b/WebVideoTranscode/WebVideoTranscodeJob.php index c4a041a..b25f4d4 100644 --- a/WebVideoTranscode/WebVideoTranscodeJob.php +++ b/WebVideoTranscode/WebVideoTranscodeJob.php @@ -541,17 +541,16 @@ $cmd .= " -qmin " . wfEscapeShellArg( $quality ); $cmd .= " -qmax " . wfEscapeShellArg( $quality ); } + // libvpx-specific constant quality or constrained quality + // note the range is different between VP8 and VP9 + if ( isset( $options['crf'] ) ) { + $cmd .= " -crf " . wfEscapeShellArg( $options['crf'] ); + } // Check for video bitrate: if ( isset( $options['videoBitrate'] ) ) { $cmd .= " -qmin 1 -qmax 51"; $cmd .= " -vb " . wfEscapeShellArg( $options['videoBitrate'] * 1000 ); - } - if ( isset( $options['vbr'] ) ) { - list( $min, $max, $buf ) = $options['vbr']; - $cmd .= " -minrate " . wfEscapeShellArg( $options['videoBitrate'] * 1000 * $min ); - $cmd .= " -maxrate " . wfEscapeShellArg( $options['videoBitrate'] * 1000 * $max ); - $cmd .= " -bufsize " . wfEscapeShellArg( $options['videoBitrate'] * 1000 * $buf ); } // Set the codec: if ( $options['videoCodec'] === 'vp9' ) { @@ -573,7 +572,6 @@ // Check for keyframeInterval if ( isset( $options['keyframeInterval'] ) ) { $cmd .= ' -g ' . wfEscapeShellArg( $options['keyframeInterval'] ); - $cmd .= ' -keyint_min ' . wfEscapeShellArg( $options['keyframeInterval'] ); } if ( isset( $options['deinterlace'] ) ) { $cmd .= ' -deinterlace'; @@ -628,7 +626,6 @@ // Check for keyframeInterval if ( isset( $options['keyframeInterval'] ) ) { $cmd .= ' -g ' . wfEscapeShellArg( $options['keyframeInterval'] ); - $cmd .= ' -keyint_min ' . wfEscapeShellArg( $options['keyframeInterval'] ); } if ( isset( $options['deinterlace'] ) ) { $cmd .= ' -deinterlace'; -- To view, visit https://gerrit.wikimedia.org/r/389900 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic48293c9666fc579f9a876a75266acadea326980 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits