Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matroska 2.2.4 breaks ts-ebml #12

Open
jony89 opened this issue Apr 18, 2022 · 1 comment
Open

matroska 2.2.4 breaks ts-ebml #12

jony89 opened this issue Apr 18, 2022 · 1 comment

Comments

@jony89
Copy link

jony89 commented Apr 18, 2022

while upgrading my app, and using ts-ebml in order to extract the record time from buffer, I got the wrong time.

not 100% sure what went wrong, but it's definitely due to moving from 2.2.3 to 2.2.4 of matroska.

https://www.npmjs.com/package/matroska/v/2.2.4

That's the code that breaks (it's being used by many):

const injectMetadata = async (blob) => {
  const decoder = new Decoder();
  const reader = new Reader();
  reader.logging = false;
  reader.drop_default_duration = false;

  const buffer = await readAsArrayBuffer(blob);
  if (!buffer) throw new Error('could not inject metadata');

  // fix for chrome 92+ with mac. getting error https://github.com/legokichi/ts-ebml/issues/33
  const validEmlType = ['m', 'u', 'i', 'f', 's', '8', 'b', 'd']; // This is from elm type of the lib
  const elms = decoder.decode(buffer)?.filter(elm => validEmlType.includes(elm.type));

  elms.forEach((elm) => { reader.read(elm); });
  reader.stop();

  const refinedMetadataBuf = tools.makeMetadataSeekable(
    reader.metadatas, reader.duration, reader.cues,
  );
  const body = buffer.slice(reader.metadataSize);
  return new Blob([refinedMetadataBuf, body], { type: blob.type });
};

so there is no specific error, but the record duration is totally wrong.

@davedoesdev
Copy link
Contributor

Update of element names to v4 should have changed the major version so dependencies didn't break.
legokichi/ts-ebml#41 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants