Giter VIP home page Giter VIP logo

videostream's Introduction

Videostream

Streams data from a file-like seekable object into a <video> or <audio> 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:

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.

videostream's People

Contributors

jhiesey avatar feross avatar jimmywarting avatar dependabot[bot] avatar amilajack avatar chocobozzz avatar daniel-abrecht avatar jimfilippou avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.