phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.37k stars 1.43k forks source link

Stream blur #19

Closed samsonradu closed 10 years ago

samsonradu commented 10 years ago

Hey, 2 questions here:

  1. Is there an efficient way to blur the incoming images to be drawn on the canvas? Currently I'm doing this but it's very CPU expensive:

    player = new jsmpeg(client,
       canvas:canvas
       ondecodeframe: ->
       boxBlurCanvasRGB("my-canvas", 0, 0, width, height, 18, 1);
       # from http://www.quasimondo.com/BoxBlurForCanvas/FastBlurDemo.html
    )
  2. Is there a way to control the incoming frame-rate? As in only draw one out of 5 incoming images?
phoboslab commented 10 years ago

Using WebGL to blur the image should be significantly faster. Try WebGLImageFilter, or blur the image with ffmpeg, before it leaves the server.

mpeg1 only supports the following frame rates: 23.976, 24.000, 25.000, 29.970, 30.000, 50.000, 59.940, 60.000. However, jsmpeg doesn't really care about these when streaming, so you may be able to specify a lower frame rate in ffmpeg that ignores the standard. Usually you specify the frame rate with the -r parameter.