Skip to content

Instantly share code, notes, and snippets.

@sky0014
Created August 8, 2022 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sky0014/491cd2c39b38515ddfec0fa6f9a00cee to your computer and use it in GitHub Desktop.
Save sky0014/491cd2c39b38515ddfec0fa6f9a00cee to your computer and use it in GitHub Desktop.
convert annex-b format to normal nalu
if (v.getUint32(offset + lengthSize) === 1) {
const bytes = new Uint8Array(
arrayBuffer,
dataOffset + offset + 4,
naluSize
);
const nals = parseNal({
codec: Codec.H264,
bytes
});
nals.nals.forEach(nal => {
const writer = new BufferWriter(
new ArrayBuffer(nal.naluData.length + 4)
);
writer.writeUint32(nal.naluData.length).write(nal.naluData);
nalArray.push(new Uint8Array(writer.buf));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment