mafintosh / mafintosh/mp4-stream

stream.decode(cb) throws Error: Data too short

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
215
Forks
22
PR merge metrics
No merged PRs in 30d

Description

When calling `stream.decode()` on the `moov` box, the mp4-box-encoding module throws an error:

```
node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:139
throw new Error('Data too short')
^

Error: Data too short
at Object.Box.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:139:11)
at exports.AudioSampleEntry.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/boxes.js:374:21)
at Object.Box.decodeWithoutHeaders (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:169:11)
at Object.Box.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:142:14)
at exports.stsd.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/boxes.js:241:21)
at Object.Box.decodeWithoutHeaders (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:169:11)
at Object.Box.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:142:14)
at Object.Box.decodeWithoutHeaders (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:155:23)
at Object.Box.decode (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:142:14)
at Object.Box.decodeWithoutHeaders (node_modules/mp4-stream/node_modules/mp4-box-encoding/index.js:155:23)
```

This is the code:

``` js
var fs = require('fs')
var mp4 = require('mp4-stream')

var stream = mp4.decode()

stream.on('box', function (headers) {
if (headers.type === 'moov') stream.decode(function () {})
else stream.ignore()
})

fs.createReadStream('./test.m4v').pipe(stream)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with test.m4v using the shown mp4-stream decoder and inspect the moov, stsd, and AudioSampleEntry decode paths in mp4-box-encoding/index.js and boxes.js. Trace why stream.decode reaches the Data too short error, then verify that decoding the same moov completes without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.