Alexander Sharov
Alexander Sharov

Reputation: 86

Is it possible to modify video stream by JavaScript

For my goals I'm using html5 and tag < video> to add a media content to page. I've found how to control video by JavaScript(stop, play, load). But is there any ways to modify processing video stream.

I'm trying to find a solutions how to add my sequence of bytes into downloaded stream: e.g modify header of file before playing.

Thanks

Upvotes: 5

Views: 2825

Answers (2)

hsivonen
hsivonen

Reputation: 8026

There's no API for modifying the video stream bytes in the video element.

You can:

  • Draw the current frame of the video element on canvas
  • Apply an SVG filter to the video element (in Gecko)
  • Use vendor-specific XMLHttpRequest extensions to read the bytes of the video file in JavaScript, modify the data, construct a data: URL from the data and load the data: URL into the video element.

Upvotes: 4

awgy
awgy

Reputation: 16924

A <video> element can be manipulated visually similarly to a <canvas> element. Take a look at this article at the Mozilla Hacks blog for a few good examples of what you can do with HTML5 video: http://hacks.mozilla.org/2009/06/pop-art-video/

But as far as modifying the actual video data stream, there isn't really a way to do that on the client side.

Upvotes: 0

Related Questions