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

Ability to handle MP4 meta atom without 4 bytes padding #1484

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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