ffmpeg txt from audio levels

2019-05-16 12:57发布

问题:

Regards community,

I want to use ffmpeg to generate a file (txt, csv) from audio values. Any idea?

I use this code to generate the audio levels:

ffplay -f lavfi "amovie=input.aac, asplit [a][out1]; [a] showvolume=f=1:b=4:w=800:h=70 [out0]"

Thank you a lot

回答1:

The command below will generate a CSV format where the first column represents the audio frame time in seconds, the second column the overall RMS dB volume for that frame, the 3rd column RMS volume for the first channel and the last column the RMS volume for the 2nd channel.

ffprobe -f lavfi -i amovie=input.aac,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

Output:

  Duration: N/A, start: 0.023220, bitrate: N/A
    Stream #0:0: Audio: pcm_f64le, 44100 Hz, stereo, dbl, 5644 kb/s
0.023220,-inf,-inf,-inf
0.046440,-inf,-inf,-inf
0.069660,-inf,-inf,-inf
0.092880,-27.330401,-22.685612,-24.414572
0.116100,-21.141091,-18.986082,-19.931269
0.139320,-20.955719,-18.549085,-19.587788
0.162540,-20.938002,-18.198237,-19.355561
0.185760,-19.852306,-20.032553,-19.941494
0.208980,-20.495281,-21.684953,-21.049508

The reset determines how often the stats are calculated. I've set the value to 1 i.e. calculated for each audio frame in isolation.



标签: csv audio ffmpeg