# videostream

> Streams data from a file-like seekable object into a `video` or `audio` node (a HTMLMediaElement)

Latest version **3.2.2** (published 2020-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install videostream
pnpm add videostream
yarn add videostream
bun add videostream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.2 |
| Published | 2020-11-12 |
| First published | 2015-03-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 289.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 246 |
| Author | John Hiesey |
| Maintainers | feross, jhiesey |

## Links

- npm: https://www.npmjs.com/package/videostream
- Repository: https://github.com/jhiesey/videostream
- Homepage: https://github.com/jhiesey/videostream#readme
- Issues: https://github.com/jhiesey/videostream/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/videostream

## Dependencies (6)

- [pump](https://npm.io/package/pump.md) ^3.0.0
- [mp4-stream](https://npm.io/package/mp4-stream.md) ^3.0.0
- [mediasource](https://npm.io/package/mediasource.md) ^2.2.2
- [binary-search](https://npm.io/package/binary-search.md) ^1.3.4
- [mp4-box-encoding](https://npm.io/package/mp4-box-encoding.md) ^1.3.0
- [range-slice-stream](https://npm.io/package/range-slice-stream.md) ^2.0.0

## Recent versions

- 3.2.2 (latest) — 2020-11-12
- 3.2.1 — 2019-08-04
- 3.2.0 — 2018-12-12
- 3.1.0 — 2018-11-27
- 3.0.0 — 2018-10-09
- 2.6.0 — 2018-09-25
- 2.5.1 — 2018-07-28
- 2.5.0 — 2018-07-28
- 2.4.3 — 2018-06-28
- 2.4.2 — 2017-01-14
- 2.4.1 — 2016-08-04
- 2.4.0 — 2016-08-04
- 2.3.0 — 2016-02-25
- 2.2.0 — 2016-02-25
- 2.1.2 — 2016-02-22
- … 18 more at https://npm.io/package/videostream/versions

## README

# Videostream

Streams data from a file-like seekable object into a &lt;video&gt; or &lt;audio&gt; node (a `HTMLMediaElement`).
Seeking the media element will request a different byte range from the incoming
file-like object.

For now only mp4 files are supported. The goal is to support
most files that conform to ISO/IEC 14496-12.

Version 2 is completely rewritten and substantially more robust
than the previous version that relied on mp4box.js. The only major regression
compared to the previous architecture is that fragmented mp4 files aren't
supported. If this is a problem I may add support again at some point.

Support for most other formats will take significant work.

## Usage

Videostream just exports a function. Use it like this:

```js
const VideoStream = require('videostream')

const exampleFile = {
  createReadStream (opts) {
    const { start, end } = opts
    // Return a readable stream that provides the bytes
    // between offsets "start" and "end" inclusive
  }
}

const video = document.createElement('video')
const videostream = new VideoStream(exampleFile, video)

video.addEventListener('error', () => {
  // listen for errors on the video/audio element directly
  const errorCode = elem.error
  const detailedError = videostream.detailedError
  // videostream.detailedError will often have a more detailed error message
})
```

### Errors

Handle errors by listening to the `'error'` event on the `<video>` or `<audio>` tag.

Some (but not all) errors will also cause `videostream.detailedError` to be set to
an error value that has a more informative error message.

## License

MIT. Copyright (c) John Hiesey.

---
_Source: https://npm.io/package/videostream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
