Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback on audio capture stats #741

Closed
padenot opened this issue Mar 7, 2023 · 7 comments · Fixed by #773
Closed

Feedback on audio capture stats #741

padenot opened this issue Mar 7, 2023 · 7 comments · Fixed by #773

Comments

@padenot
Copy link

padenot commented Mar 7, 2023

Being able to know the input latency is a welcome change, but there are a number of problems with the prose:

totalSamplesCaptured: this should be named totalFramesCaptured, to handle multichannel and to be consistent with the rest of the Web Platform. A frame can contain multiple samples (one per audio channel).

droppedSamplesDuration: it's unclear what this means. When does a capture device drop audio? It is because of a catastrophic real-time load problem? A bug in the implementation?

The frequency of the media source is necessarily the same as the frequency of encoders later in pipeline.

This is using incorrect terminology, I think this is referring to the sampling-rate or sampling-frequency, not the frequency.

@henbos
Copy link
Collaborator

henbos commented Mar 7, 2023

Samples rather than frames were chosen for consistency with other metrics (we consistently use samples rather than frames when it comes to audio, e.g. totalSamplesReceived). This might not be ideal in hindsight, but it is addressed in the Terminology section:

An audio sample refers to having a sample in any channel of an audio track - if multiple audio channels are used, metrics based on samples do not increment at a higher rate, simultaneously having samples in multiple channels counts as a single sample.

When does a capture device drop audio?

If the browser has a polling based model it may not be able to keep up with all the samples in all circumstances, though I am not the audio expert here. I can try to figure out more information about this if you like

@henbos
Copy link
Collaborator

henbos commented Mar 8, 2023

Asked the audio experts, they said "The capture device is a realtime device and if the browser does not process them in a timely manner it has to drop them"

@padenot
Copy link
Author

padenot commented Mar 8, 2023

Right, so this is when a "catastrophic real-time load problem" occurs, which makes sense.

We need to revert this and have something on the MediaStream that represents an audio input device, or something like this.

It's not desirable to have coupling between the audio input system and WebRTC, and it's best to use the terms used in the industry and the rest of the Web Platform. gUM is frequently used without anything related to WebRTC, and knowing the input latency is capital in those scenarios (e.g., anything related to synchronizing recordings).

@henbos
Copy link
Collaborator

henbos commented Mar 8, 2023

Having media source metrics is not new and having measurements of glitches seem to fit well together with existing sample counters and audio energy metrics that we already get from the track and expose via getStats.

That said, general solutions are nice to have. Historically it has been difficult to add any metrics to the MediaStreamTrack interface, but given the recent extension API MediaStreamTrack.getFrameStats() (which expose similar counters to media-source.frames, but also counters for frame drops and don't require attachment to WebRTC) I could certainly imagine something like track.getAudioStats() providing information about sample drops.

@vr000m
Copy link
Contributor

vr000m commented Mar 15, 2023

Linking to semi related for multi-channel, stereo metrics #686

@dontcallmedom-bot
Copy link

@henbos
Copy link
Collaborator

henbos commented May 30, 2023

This work was moved to the track stats (webrtc-extension) spec, if that PR can merge then we should delete the stats from this document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants