w3c / webrtc-nv-use-cases

Use cases for WebRTC NV
https://w3c.github.io/webrtc-nv-use-cases/
Other
32 stars 13 forks source link

API for codec performance #41

Closed aboba closed 1 year ago

aboba commented 5 years ago

Copied from Issue https://github.com/w3c/webrtc-pc/issues/2241

Hi Group,

I work on the MediaCapabilities (MC) spec (explainer). I've had a few requests from WebRTC apps to expand this API to describe WebRTC encode/decode performance. The use cases make sense but I have some ergonomics concerns and I'd like to collab w/ RTC experts here to explore the options.

MediaCapabilities today

WebRTC use cases are very similar to those from the media playback world. Apps would like to know before-hand what limits to set for resolution/framerate/bitrate such that the machine is able to maintain a buttery smooth (timely) user encoding/decoding experience (ignoring the small matter of network issues). WebRTC's reference implementation helps out by automatically adapting encode resolution if the CPU is over-used, but this requires the user to first have a bad experience before adapting back down (meanwhile, the camera may be left open at HD resolution, potentially wasting resources of a starving machine).

Apps may also ask what codecs can be hardware accelerated to minimize battery drain.

Ergonomics: What shape should the API take? Where should it live? We took a closer look at implementing MC.encodingInfo() for "transmission" (WebRTC) encoding in Chrome, and a few things gave me pause.

Most notably, WebRTC has existing capability APIs that seem like a natural place to describe codec performance.

Another issue we face is that WebRTC doesn't use the same mime-type codec strings from the \<video> playback world (e.g. 'video/mp4; codecs="avc1.4d001e"' for \<video> vs 'video/h264' in RTC). Its a little ugly to consider mixing these into MediaCapabilities and it smells like a hint that we're merging two worlds that might better be kept separate.

Interested to get your thoughts! Thanks for reading.

aboba commented 1 year ago

The MediaCapabilities() API has been extended to support WebRTC. It can now indicate whether it is possible that encode or decode operations will be hardware accelerated.