Drawing streaming video to canvas

Openfl vers : 7.0.0
workflow: Npm
target: Html5

Hi , all I’m using H26bsd js lib ,streaming video data via websocket
currently it’s work by making new canvas element , does anyone know how to draw the data to openfl main canvas , or how to get the main stage canvas element in the context(‘2d’) , since getContext2d only work if I make new instance of CanvasElement ,


First, it would be interesting to consider adding support for the library internally within OpenFL. We support playback of video at the moment, but streaming video is something we would like to support.

Now, that said, there’s a few ways you can mix your own canvas element in.

Use the “dom” renderer, and you can add a new openfl.display.DOMSprite with your own element. This could be your CanvasElement, and you can mix it in the display list.

If you must render to a single canvas, then BitmapData.fromCanvas might help, but I believe it may expect to do a single copy, once, and not continue to sync with the source canvas. There may also be ways to use lime.graphics.ImageBuffer to create your own buffer (using buffer.src = canvas), then a new lime.graphics.Image using the buffer, then BitmapData.fromImage to create a BitmapData that way, which you can use in your code.

Please post if you have more questions, or run into bumps


Thx for the reply ,
will investigate more for video streaming in openfl ,

Streaming is something I’d like to add to my projects to enhance visual quality and variety, it is a very big deal for Openfl, I think: I am going to develop an app playing mp4 videos, but streaming would be a step ahead.

EDIT: but, hey… streaming is already in Openfl! Does the “PlayingVideo” sample use streaming?

still experimenting ffmpeg streaming to openfl html5

Is it your experiment? Or you are trying something different?

openfl can stream the mp4 etc . but for video through binary streaming still doesn’t work yet

Ah ok! Sorry, I missed this detail :wink:

no problem , will post if i got some good result

Any update about video streaming?