austinleroy / node-ebml

EBML parser
MIT License
13 stars 4 forks source link

EbmlStreamDecoder fails when not aligned to a cluster #3

Open ThaUnknown opened 1 year ago

ThaUnknown commented 1 year ago

EbmlStreamDecoder will not output any data if the stream starts in the middle of a file ex:

import { createReadStream } from 'node:fs'
import { EbmlStreamDecoder } from 'ebml-stream'
const decoder = new EbmlStreamDecoder({
  bufferTagIds: [
    EbmlTagId.TimecodeScale,
    EbmlTagId.Tracks,
    EbmlTagId.BlockGroup,
    EbmlTagId.AttachedFile
  ]
})
decoder.on('data', console.log) // never ran

const stream = createReadStream('./video.mkv', { start: 2392064, end: 23920640 })
stream.on('data', data => decoder.write(data))
stream.pipe(subtitle).pipe(devnull())