Real-time video processing with WebCodecs and Streams��https://github.com/tidoust/media-tests/
TPAC 2023 - Technical demo
September 2023
François Daoust - W3C - fd@w3.org - @tidoust
Scenarios that require processing�video frames in real-time
Media stream analysis
Media stream manipulation
Reasoning about memory copies is hard!
Example: optimization… or not
Timer | Memory | Frames | Avg. | Median |
toRGBX | GPU | 247 | 0 | 0 |
| | | | |
encode | GPU? CPU? | 247 | 17 | 15 |
decode | GPU? CPU? | 247 | 1 | 1 |
end2end | | 247 | 24 | 17 |
queued | | 247 | 6 | 0 |
Timer | Memory | Frames | Avg. | Median |
toRGBX | GPU | 256 | 0 | 0 |
background | CPU - WASM | 256 | 13 | 12 |
encode | GPU? CPU? | 255 | 8 | 7 |
decode | GPU? CPU? | 255 | 1 | 1 |
end2end | | 255 | 28 | 21 |
queued | | 255 | 6 | 0 |
All on the GPU where processing is cheap!�Unfortunately, browser likely used a CPU-bound encoder on my machine…
Adding a slow processing step in WebAssembly. End-to-end time increase is just ~4ms as encoding times dropped. One less copy needed, probably!
Rough illustration of memory boundaries in browsers
CPU
GPU
I/O
📶
📷
🎤
🔈
📺
ML hardware / FPGA
Hardware media encoders / decoders
JavaScript�land
WASM land
WebGPU/WebGL land
Browser
Main
Worker
Worker
Ongoing web media standardizations and groups
Ongoing media standardizations