Linux – How do I get the Overall.RMS_level in real time from a UDP stream as an integer attached to the log file?

My goal is to monitor the audio of a UDP stream in real time to see if the audio is missing or too quiet. At the end, attach to a log file that contains the integer values ​​in decibels.

I've tried ffprobe and ffmpeg and the only valid output I could get is using ffmpeg.

ffmpeg gives the correct results, however the output file specified as "log.txt" is open for the output lock of ffmpeg and no data is written to it until you press Ctrl-C to end the process at the time when the output file is closed. I'm going to write a script to query the output file in real time as the file is being written, but only if I can figure out how to instruct ffmpeg to append "log.txt" for each sample taken.

Please provide an alternative method or a solution for this method.

Attempt 1 using ffmpeg

ffmpeg -i 'udp://@' -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level:file=log.txt -f null -

Example of the contents of the "log.txt" file according to Ctrl-C

frame:0    pts:0       pts_time:0
frame:1    pts:1536    pts_time:0.032
frame:2    pts:3072    pts_time:0.064
frame:3    pts:4609    pts_time:0.0960208

Experiment 2 Using ffprobe

ffprobe -i 'udp://@',astats=metadata=1:reset=1 -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.RMS_level,lavfi.astats.1.RMS_level,lavfi.astats.2.RMS_level -of csv=p=0

This works and only shows the time code. Empty lines are shown in the console output for lavfi.astats.Overall.RMS. I think the problem has to do with lavfi?

Sample output to the console:




I tried to change the command line to specify -f-lavfi before typing -i, but it returned an error:

ffprobe -f lavfi  -i 'udp://@',astats=metadata=1:reset=1 -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.RMS_level,lavfi.astats.1.RMS_level,lavfi.astats.2.RMS_level -of csv=p=0


[lavfi @ 0x55c69784f840] No such filter: 'udp://'
udp://@,astats=metadata=1:reset=1: Invalid argument