[FFmpeg-devel] [PATCH] libavfilter/af_showvolume: A Simple Audio Filter for Extracting Volume Information

Lars Kiesow lkiesow at uos.de
Mon Dec 22 16:50:57 CET 2014


Hi everyone,
I'm an FFmpeg user for quite a while now and though I might as well
switch to dev at some point...

Please find attached to this mail a simple audio filter which makes it
possible to extract and print volume information from audio streams. It
works more or less like the showinfo filters only that it returns the
pcm value information for each audio sample.

This output can then be used to easily plot a waveform image like this:
  http://larskiesow.de/waveform.png


Example:
./ffmpeg -nostats -i ... -filter:a aresample=100,showvolume -f null -
  [...]
  [Parsed_showvolume_1 @ 0x1bcc300] n: 0, channel: 0, volume: -239
  [Parsed_showvolume_1 @ 0x1bcc300] n: 1, channel: 0, volume: 126
  [Parsed_showvolume_1 @ 0x1bcc300] n: 2, channel: 0, volume: -74
  [Parsed_showvolume_1 @ 0x1bcc300] n: 3, channel: 0, volume: 29
  [...]

Example (Generate waveform using gnuplot):
./ffmpeg -nostats -i ... -ac 1 -filter:a aresample=100,showvolume \
  -f null - 2>&1 | grep '^\[Parsed_showvolume_1' | \
  gnuplot -p -e 'plot "-" using 9 with lines'


The code can be found at
https://github.com/lkiesow/FFmpeg/tree/libavfilter-audio-showvolume
and is also attached to this mail split into three separate patches.

The first patch contains the filter itself, the necessary changes to
allfilters.c and the build files. The second patch contains the
documentation. Finally, the third patch contains a small script added
to the tools section utilizing the showvolume filter for generating
waveform images with gnuplot.

Please let me know if you think it makes sense to add this code to
ffmpeg and/or if anything is still missing.

Regards,
Lars
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-showvolume-audio-filter.patch
Type: text/x-patch
Size: 5861 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141222/2256510c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-documentation-for-showvolume-filter.patch
Type: text/x-patch
Size: 1261 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141222/2256510c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Added-script-for-waveform-generation-to-tools.patch
Type: text/x-patch
Size: 2640 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141222/2256510c/attachment-0002.bin>


More information about the ffmpeg-devel mailing list