Brion VIBBER has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/388934 )
Change subject: Adjust VP9 encoding options
......................................................................
Adjust VP9 encoding options
Adjusted the encoding options for WebM VP9 video transcodes
(not yet used in production).
* bumped bandwidth from 50% to 62.5% of the VP8 versions
* use 2-pass on all resolutions instead of just some
* use -speed 4 on first pass, -speed 1 on second pass
* use -auto-alt-ref 1 -lag-in-frames 25
* bump keyframe max interval up to 240 from 128
Still 2-4x slower than VP8 encoding, but quality matches
better now.
Change-Id: I731a6ca7e7cd0fd8f9e80f2f2cb406abe4edea7e
---
M WebVideoTranscode/WebVideoTranscode.php
M WebVideoTranscode/WebVideoTranscodeJob.php
2 files changed, 56 insertions(+), 27 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler
refs/changes/34/388934/1
diff --git a/WebVideoTranscode/WebVideoTranscode.php
b/WebVideoTranscode/WebVideoTranscode.php
index b444c08..0e79906 100644
--- a/WebVideoTranscode/WebVideoTranscode.php
+++ b/WebVideoTranscode/WebVideoTranscode.php
@@ -269,11 +269,13 @@
[
'maxSize' => '288x160',
'videoBitrate' => '80',
+ 'vbr' => [ 0.5, 1.5, 10
], // min bitrate, max bitrate, buffer size ratios
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'type' => 'video/webm;
codecs="vp9, opus"',
@@ -281,12 +283,14 @@
self::ENC_VP9_240P =>
[
'maxSize' => '426x240',
- 'videoBitrate' => '128',
+ 'videoBitrate' => '150',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'type' => 'video/webm;
codecs="vp9, opus"',
@@ -294,12 +298,14 @@
self::ENC_VP9_360P =>
[
'maxSize' => '640x360',
- 'videoBitrate' => '256',
+ 'videoBitrate' => '320',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '1',
@@ -308,12 +314,14 @@
self::ENC_VP9_480P =>
[
'maxSize' => '854x480',
- 'videoBitrate' => '512',
+ 'videoBitrate' => '640',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '1',
@@ -322,12 +330,14 @@
self::ENC_VP9_720P =>
[
'maxSize' => '1280x720',
- 'videoBitrate' => '1024',
+ 'videoBitrate' => '1280',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '2',
@@ -336,12 +346,14 @@
self::ENC_VP9_1080P =>
[
'maxSize' => '1920x1080',
- 'videoBitrate' => '2048',
+ 'videoBitrate' => '2560',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '4',
@@ -350,12 +362,14 @@
self::ENC_VP9_1440P =>
[
'maxSize' => '2560x1440',
- 'videoBitrate' => '4096',
+ 'videoBitrate' => '5120',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '4',
@@ -363,13 +377,15 @@
],
self::ENC_VP9_2160P =>
[
- 'maxSize' => '4096x2160',
- 'videoBitrate' => '8192',
+ 'maxSize' => '3840x2160',
+ 'videoBitrate' => '10240',
+ 'vbr' => [ 0.5, 1.5, 10
],
'samplerate' => '48000',
- 'noUpscaling' => 'true',
'twopass' => 'true',
- 'keyframeInterval' => '128',
+ 'altref' => 'true',
+ 'keyframeInterval' => '240',
'bufDelay' => '256',
+ 'speed' => '1',
'videoCodec' => 'vp9',
'audioCodec' => 'opus',
'tileColumns' => '4',
diff --git a/WebVideoTranscode/WebVideoTranscodeJob.php
b/WebVideoTranscode/WebVideoTranscodeJob.php
index cec23b2..f039249 100644
--- a/WebVideoTranscode/WebVideoTranscodeJob.php
+++ b/WebVideoTranscode/WebVideoTranscodeJob.php
@@ -534,9 +534,6 @@
}
}
- // Add the boiler plate vp8 ffmpeg command:
- $cmd .= " -skip_threshold 0 -bufsize 6000k -rc_init_occupancy
4000";
-
// Check for video quality:
if ( isset( $options['videoQuality'] ) &&
$options['videoQuality'] >= 0 ) {
// Map 0-10 to 63-0, higher values worse quality
@@ -550,6 +547,12 @@
$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' ) {
$cmd .= " -vcodec libvpx-vp9";
@@ -562,6 +565,10 @@
$cmd .= ' -slices ' . wfEscapeShellArg(
$options['slices'] );
}
}
+ if ( isset( $options['altref'] ) ) {
+ $cmd .= ' -auto-alt-ref 1';
+ $cmd .= ' -lag-in-frames 25';
+ }
// Check for keyframeInterval
if ( isset( $options['keyframeInterval'] ) ) {
@@ -571,6 +578,12 @@
if ( isset( $options['deinterlace'] ) ) {
$cmd .= ' -deinterlace';
}
+ if ( $pass == 1 ) {
+ // Make first pass faster...
+ $cmd .= ' -speed 4';
+ } elseif ( isset( $options['speed'] ) ) {
+ $cmd .= ' -speed ' . wfEscapeShellArg(
$options['speed'] );
+ }
// Output WebM
$cmd .= " -f webm";
--
To view, visit https://gerrit.wikimedia.org/r/388934
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I731a6ca7e7cd0fd8f9e80f2f2cb406abe4edea7e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
