Skip to content

Commit

Permalink
Ability to handle MP4 meta atom without 4 bytes padding
Browse files Browse the repository at this point in the history
Workaround for issue #1390
  • Loading branch information
Borewit committed Nov 27, 2022
1 parent 72a4006 commit afcc874
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mp4/Atom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import initDebug from 'debug';
import * as AtomToken from './AtomToken.js';
import { Header } from './AtomToken.js';

import { ITokenizer } from 'strtok3/core';

Expand Down Expand Up @@ -66,8 +67,10 @@ export class Atom {

case 'meta': // Metadata Atom, ref: https://developer.apple.com/library/content/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW8
// meta has 4 bytes of padding, ignore
await tokenizer.ignore(4);
return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining) - 4);
const peekHeader = await tokenizer.peekToken(Header);
const paddingLength = peekHeader.name === 'hdlr' ? 0 : 4;
await tokenizer.ignore(paddingLength);
return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining) - paddingLength);

case 'mdhd': // Media header atom
case 'mvhd': // 'movie' => 'mvhd': movie header atom; child of Movie Atom
Expand Down

0 comments on commit afcc874

Please sign in to comment.