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

"audio-peak-value" property #2645

Closed
lukaszmatczak opened this issue Dec 28, 2015 · 8 comments
Closed

"audio-peak-value" property #2645

lukaszmatczak opened this issue Dec 28, 2015 · 8 comments

Comments

@lukaszmatczak
Copy link

Currently, external apps must use OS-dependent API to retrieve peak value of audio stream, for example IAudioMeterInformation::GetPeakValue() on Windows. Is it possible to add property like "audio-peak-value" accessible from Lua script?

@ghost
Copy link

ghost commented Dec 28, 2015

There might be a filter in libavfilter which can compute this value; then it should be retrieved with the af-metadata property.

@lukaszmatczak
Copy link
Author

Sounds great. I'm waiting for this feature. Thank you for help!

@ghost
Copy link

ghost commented Dec 30, 2015

Well, the mechanisms are already all there.

I'm not sure whether libavfilter actually has a filter which does this. I thought the volumedetect filter does, but it merely prints the stats on the terminal at deinitialization, instead of passing it through the API.

Maybe @richardpl is interested in implemented a filter that does this?

@richardpl
Copy link
Contributor

If I'm not mistaken there is already filter that reports bunch of info including max and min sample value in audio, it works with floats and its name is astats.

@ghost
Copy link

ghost commented Jan 14, 2016

Indeed, looks like this should work.

For some really weird reason, it requires a metadata suboption to be set.

@lukaszmatczak
Copy link
Author

Works excellent. Thank you!

@dweymouth
Copy link

@lukaszmatczak this was years ago but if you happen to remember how you did this I'd love if you could share some sample code. I am trying to do the same thing to add a peak meter to my music player app that uses libmpv but I can't figure it out!

@lukaszmatczak
Copy link
Author

@dweymouth I've used code like this:

function send_state()
    local astats = mp.get_property_native("af-metadata/level")

    if astats ~= nil then
        print(astats["lavfi.astats.Overall.Max_level"])
    end
end

mp.add_periodic_timer(0.1, send_state)

And then I could read the current level in the parent process from mpv's stdout.

Also, I had to add --af=@level:lavfi="astats=metadata=1:reset=4" to the command line options.

Please note that this code is quite old and there may be a better solution now.

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

No branches or pull requests

3 participants