Skip to content

Commit

Permalink
fix(mp4-tools): set default color descriptions to satisfy Firefox
Browse files Browse the repository at this point in the history
In Firefox either you omit the chroma values, or you have to complete the rest of the color descriptions.

Otherwise even the most basic AV1 Main 4:2:0 8-bit video will be reported as unsupported
in HTMLMediaElement.canPlayType and MediaSource.isTypeSupported. Chromium is not affected by this.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
  • Loading branch information
nyanmisaka committed Sep 1, 2023
1 parent 7e29dc6 commit 05737e6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/utils/mp4-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ function parseStsd(stsd: Uint8Array): { codec: string; encrypted: boolean } {
const chromaSubsamplingX = (av1CBox[2] & 0x08) >> 3;
const chromaSubsamplingY = (av1CBox[2] & 0x04) >> 2;
const chromaSamplePosition = av1CBox[2] & 0x03;
// TODO: parse color_description_present_flag
// default it to BT.709/limited range for now
const colorPrimaries = 1;
const transferCharacteristics = 1;
const matrixCoefficients = 1;
const videoFullRangeFlag = 0;
codec +=
'.' +
profile +
Expand All @@ -382,7 +388,15 @@ function parseStsd(stsd: Uint8Array): { codec: string; encrypted: boolean } {
'.' +
chromaSubsamplingX +
chromaSubsamplingY +
chromaSamplePosition;
chromaSamplePosition +
'.' +
addLeadingZero(colorPrimaries) +
'.' +
addLeadingZero(transferCharacteristics) +
'.' +
addLeadingZero(matrixCoefficients) +
'.' +
videoFullRangeFlag;
break;
}
case 'ac-3':
Expand Down

0 comments on commit 05737e6

Please sign in to comment.