From 136348d2215a951f8395a79d63f930fc95d9593f Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 8 Aug 2022 23:26:40 -0700 Subject: [PATCH] fix: Fix VP9 codec checks on Mac Firefox (#4391) Tests for VP9 codec checks were failing on Firefox on our M1 Mac. This addresses the issue by changing some default values that get used in a testing environment, and another default value that is used in production. --- lib/util/stream_utils.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index ee0ca77220..6e44d9582d 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -578,8 +578,16 @@ shaka.util.StreamUtils = class { // VideoConfiguration mediaDecodingConfig.video = { contentType: fullType, - width: video.width || 1, - height: video.height || 1, + + // NOTE: Some decoders strictly check the width and height fields and + // won't decode smaller than 64x64. So if we don't have this info (as + // is the case in some of our simpler tests), assume a 64x64 resolution + // to fill in this required field for MediaCapabilities. + // + // This became an issue specifically on Firefox on M1 Macs. + width: video.width || 64, + height: video.height || 64, + bitrate: video.bandwidth || variant.bandwidth || 1, // framerate must be greater than 0, otherwise the config is invalid. framerate: video.frameRate || 1, @@ -742,7 +750,19 @@ shaka.util.StreamUtils = class { */ static patchVp9(codec) { if (codec == 'vp9') { - return 'vp09.00.10.08'; + // This means profile 0, level 4.1, 8-bit color. This supports 1080p @ + // 60Hz. See https://en.wikipedia.org/wiki/VP9#Levels + // + // If we don't have more detailed codec info, assume this profile and + // level because it's high enough to likely accommodate the parameters we + // do have, such as width and height. If an implementation is checking + // the profile and level very strictly, we want older VP9 content to + // still work to some degree. But we don't want to set a level so high + // that it is rejected by a hardware decoder that can't handle the + // maximum requirements of the level. + // + // This became an issue specifically on Firefox on M1 Macs. + return 'vp09.00.41.08'; } return codec; }