ThibaultBee / StreamPack

SRT/RTMP/RTMPS live streaming libraries for Android
https://thibaultbee.github.io/StreamPack/index.html
Apache License 2.0
193 stars 69 forks source link

Is it possible to access Audio buffers to retrieve info for a VUMeter? #39

Open ruirodrigues-eyenov opened 2 years ago

ruirodrigues-eyenov commented 2 years ago

Basically I would like to show a VUmeter with the audio volume/gain/amplitude being sent when streaming. I could not found any way, I wonder if that is possible? Thanks

ThibaultBee commented 2 years ago

Hello :)

I was kind of expecting this request. There is a branch where you can get peak and/or rms value of each audio channels: https://github.com/ThibaultBee/StreamPack/tree/feature/vu-meter. I just rebased it. Is it what you are looking for? Are you going to use rms and/or peak value?

The only things missing for now is that when preview is running, you won't get any value cause audio capture is not running and I still don't really know how to implement this part.

Regards, Thibault

ruirodrigues-eyenov commented 2 years ago

Hello :)

this is great! exactly what I wanted! thanks :)

I don't need the values while previewing but from what I can understand you can just startRecording on the AudioRecord and discard the Frames after getting the measurements.

ThibaultBee commented 2 years ago

Hi, This is the issue: there aren't any audio frames when encoder is not running. It means that you can only access audio frame when StreamPack is live streaming.

ruirodrigues-eyenov commented 2 years ago

Yes, I know. To get audio frames you need to start recording when preview starts and discard audio frames instead of streaming them. But in my case this isn't an issue at all.

Another question on a different matter: Is it possible to get any metrics from streaming? just wondering :)

ThibaultBee commented 2 years ago

What metrics do you have in mind?

ruirodrigues-eyenov commented 2 years ago

latency, bandwidth, frame rate, bitrate. I am not sure if those are possible at all.

ThibaultBee commented 2 years ago

Do you use SRT or RTMP? I guess it is quite easy to return latency, bandwidth and network bitrate with SRT, not sure about RTMP.

ruirodrigues-eyenov commented 2 years ago

SRT 😄