I'm using FFprobe to get MAX_level stats from audio.
This ffprobe command use my_audio_file.mp3 as input file to generate MAX_level for every frame.
ffprobe -f lavfi -i amovie=my_audio_file.mp3,astats=metadata=1:reset=1 -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.MAX_level -of csv=p=0 1> my_output_log.txt
When I execute it, I get generated my_output_log.txt file with frame time and MAX_level value for this frame in the csv format. (1 column - frame time | 2 column - MAX_level for this frame)
You can see that MAX_level (2nd column) value generates every 0,026122
seconds. So, if you count all frames for 0 second, you got 39 frames. Input file duration = 3m 20s, then I get output file with +-8000 MAX_level values, but I need only 200 MAX_level values.
0.000000,0.000000
0.026122,0.000000
0.052245,0.000000
0.078367,0.000000
0.104490,0.000000
0.130612,0.000000
0.156735,0.000000
0.182857,0.000000
0.208980,0.000000
0.235102,1.000000
0.261224,5792.000000
0.287347,9111.000000
0.313469,9847.000000
0.339592,9208.000000
0.365714,8498.000000
0.391837,9649.000000
0.417959,12201.000000
0.444082,11763.000000
0.470204,9013.000000
0.496327,9048.000000
0.522449,8826.000000
0.548571,9932.000000
0.574694,9382.000000
0.600816,9013.000000
0.626939,8052.000000
0.653061,8317.000000
0.679184,5445.000000
0.705306,6925.000000
0.731429,7136.000000
0.757551,7029.000000
0.783673,7610.000000
0.809796,9199.000000
0.835918,8443.000000
0.862041,7847.000000
0.888163,6878.000000
0.914286,7385.000000
0.940408,9294.000000
0.966531,8105.000000
0.992653,8620.000000
1.018776,7286.000000
<38 frames>
2.011429,4573.000000
2.037551,5155.000000
2.063673,4527.000000
<etc>
because I execute this command on the android device which generates it 17 seconds.
The output should be like this:
0.000000,0.000000
1.018776,7286.000000
2.011429,4573.000000
3.004082,9935.000000
4.022857,6132.000000
<frame per second>
200.012457,1002.000000
You can modify or use another ffprobe command to get correct result.
Use asetnsamples to consolidate 1 second's worth of media into 1 frame.
ffprobe -f lavfi -i amovie=my_audio_file.mp3,asetnsamples=44100,astats=metadata=1:reset=1 -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.MAX_level -of csv=p=0 1> my_output_log.txt
Set asetnsamples value to the sampling rate of the input.