Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Riffing off those, here's a ffmpeg/mpv command to run an audio frequency spectrum visualizer on a live microphone (or a virtual loopback one):

   ffmpeg -f avfoundation -i ":0" -flush_packets 1 -flags low_delay -muxdelay 0.01 -fflags nobuffer -f wav -c copy - | mpv - --profile=low-latency -untimed --lavfi-complex="[aid1]showcqt=fps=30:s=1280x720:count=5:axis=1:axis_h=6:bar_h=100:timeclamp=0.13[vo]" 
Specifically it's using ffmpeg's showcqt[0] filter, which I find to be by far ffmpeg's most beautiful/comprehensible frequency visualizer. In my example `-i ":0"` refers to my microphone at index "0". To find your system's microphone index you can run `ffmpeg -f avfoundation -list_devices true -i ""`.

here's a screenshot: https://dl.dropboxusercontent.com/s/yx5rlgpsmai3kej/showcqt_...

[0] https://ffmpeg.org/ffmpeg-filters.html#showcqt



Nice, thanks, just tried it, that's quite cool, saving it for later! Any reason you are running the filters within the `mpv` command vs within the `ffmpeg` command? I honestly have no idea which way is "better" if any, I think underneath both actually use `libavfilter` library?


They’re both the same really! Though I prefer doing the visualizing in mpv because than it’s easier to switch to different visualizations at runtime. With my mpv config I have obscure keyboard shortcuts that'll switch between different ones. But also possible to do it without mpv entirely.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: