w3c / mediacapture-extensions

Extensions to Media Capture and Streams by the WebRTC Working Group
https://w3c.github.io/mediacapture-extensions/
Other
19 stars 14 forks source link

MediaStreamTrack: actual frame rates captured #76

Closed henbos closed 1 year ago

henbos commented 1 year ago

Sub-issue of https://github.com/w3c/mediacapture-main/issues/826.

track.getSettings() already gives us the setting (assuming https://github.com/w3c/mediacapture-main/issues/906 is fixed), but it's still useful to know what the actual frame rate is as it could be lower if...

Edit: New proposal:

Previous proposal: track.framesEmitted + track.framesDropped = framesCaptured

jan-ivar commented 1 year ago

Don't we already have this in stats for peer connection-related use cases? Also works outside of peer-connection in a pinch.

For playback, frame-rates appear measurable on the video element in Chrome and Firefox (dunno what Safari has here). What other use cases are there?

jan-ivar commented 1 year ago

track.framesEmitted: Total counter of frames emitted by the source.

This explanation confused me. In the PR it appears to instead be frames emitted by the track to its consumer, not the total frame count of the (camera) source. Which is it?

henbos commented 1 year ago

@jan-ivar "media-source" frame rates need to be clarified... historically they are the standardized version of "googFrameRateInput". In contrast to the send FPS or encoder FPS, this is the "input FPS", i.e. the rate of frames being input to WebRTC. So with zero frame drops within WebRTC, the media-source's FPS was the maximum possible FPS you could achieve as the send FPS. But frame drops happening prior to WebRTC is not visible in getStats().

Frame producer (e.g. Camera) --> Media Source --> Frame consumer
                              |                |
                              |          framesEmitted
                              |
            framesDropped = delta between framesProduced and framesEmitted (not in getStats)

Arguably you could add framesDropped to getStats(), but there are several use cases where we want to know about framesDropped or framesProduced where WebRTC isn't involved. What would be the argument for adding metrics useful outside of WebRTC to WebRTC specific APIs? Why not just add them to the track?

henbos commented 1 year ago

track.framesEmitted: Total counter of frames emitted by the source.

This explanation confused me. In the PR it appears to instead be frames emitted by the track to its consumer, not the total frame count of the (camera) source. Which is it?

I was avoiding saying "source FPS" because that begs the question if we're talking about FPS that was produced for the source or FPS emitted from the source (i.e. that was not dropped on the way between producer and source).

There are three interesting frame rates, and none of them are specific to WebRTC:

henbos commented 1 year ago

Changed this to only include framesCaptured