Add support for SAMPLE-AES and SAMPLE-AES-CTR decryption, add "Common Encryption" support to ISOBMFF demuxer, add InputFormatOptions, rewrite ISOBMFF track codec resolution

This commit is contained in:
Vanilagy
2026-04-22 16:54:49 +02:00
parent 5e8d0b25a0
commit 493ef50820
9 changed files with 1025 additions and 195 deletions
+11
View File
@@ -199,10 +199,21 @@ export class AsyncMutex {
}
}
export const HEX_STRING_REGEX = /^[0-9a-fA-F]+$/;
export const bytesToHexString = (bytes: Uint8Array) => {
return [...bytes].map(x => x.toString(16).padStart(2, '0')).join('');
};
export const hexStringToBytes = (hexString: string) => {
assert(hexString.length % 2 === 0);
const bytes = new Uint8Array(hexString.length / 2);
for (let i = 0; i < hexString.length; i += 2) {
bytes[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
}
return bytes;
};
export const reverseBitsU32 = (x: number): number => {
x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);