-
Notifications
You must be signed in to change notification settings - Fork 15
Description
One of the options mentioned in #3 is the use of an mpeg4 stream. I don't think it's worth the effort to look into it now, but let's collect some thoughts and findings here.
Front-end
Let's start with the easy part. Could be a <video>
object, or using the webCRT API.
MPEG4 encoding
We'd need to encode the images as an mpeg4 stream. Some options:
- imageio-ffmpeg - can currently only write to a file on the filesystem. Maybe it can be changed to pipe the result back to Python? Moving the data down pipes will come with a performance penalty though.
- ffmpeg-python - pretty sure this one can do in-memory encoding.
We'd need to set things up so that the encoding is suited for a stream (e.g. variable framerate, minimal buffering).
Streaming the video
If the server would host a web server, in the form of an URL endpoint that provides a streaming http connection, we can probably push the frames over it. Disclaimer: I've worked with video encoding and web servers, but never combined.
WebCRT
Browsers have an API for streaming video called WebCRT, which may (or may not) make the implementation easier. See e.g. https://github.com/maartenbreddels/ipywebrtc
We'd need an implementation of WebCRT in Python, and that should include mpeg4 encoding (see above). This would be a lot of code/work, unless there exists a library for that.
Something to keep in mind is that the current throttling mechanism schedules the server-side drawing based on how fast the client can display the images. This seems to work very well, and if we'd ever implement WebCRT we should make sure to have a similar coupling.
General thoughts
- This only touches on one aspect of performance, see the top post in Performance #3.
- Using jpeg's will already be a huge improvement. Using mpeg4 also applies temporal encoding, but I don't expect the gain to be huge.
- I expect that mpeg4 encoding will make the code a lot more complex.
- Heavy dependencies.
My current view is that it's not worth the effort. But let's keep the discussion open for the time being.