Max's Stuff

TIL: fix cut off sounds on Bluetooth headphones using FFmpeg

Published:

This is a “today I learned” that I actually learned back in October/November and forgot to write up. :) Anyways…

From what I can tell, many Bluetooth audio devices quickly disconnect from their audio source after playing and automatically reconnect when needed. This probably works well for most pieces of media, but it can be extremely annoying when what you’re playing has a really short duration, e.g. word pronunciations in Anki, because the beginning and end1 of the clip can be cut off. Imagine the word “ba-na-na” sounding like “a-na-n”!

I don’t really understand how this is still a problem in $CURRENT_YEAR, but it is. There are so many Reddit threads about it with hacky solutions like “play quiet white noise” or “open up a YouTube video in the background”… Here’s how I solved it with a “simple” FFmpeg command:

ffplay -nodisp -f lavfi -i anullsrc=r=44100:cl=stereo

I’ll be honest, ChatGPT helped me out with this. My initial solution was to use afplay on macOS but I couldn’t come up with a good one-liner I liked. Its explanation is that this plays an endless silent audio stream (anullsrc via lavfi) with no display output (-nodisp) to prevent the disconnects from happening, and it’s been working for me for months.

Hope this helps!


  1. Yes, the end too. I understand how the beginning could be cut off (maybe the O.S. starts “playing” the audio before the Bluetooth device is ready?), but why the end can also get cut off has me very confused. ↩︎

#til