ffmpeg 7 doesn’t work with Audacity 3.5 as I’ve found out the hard way.
If you are running brew on Mac Monterey and using it to install ffmpeg for Audacity, you must install ffmpeg 6. It can be installed along side ffmpeg 7 (which is the latest version at the time of this writing and gets installed with a simple brew install ffmpeg).
$ brew install ffmpeg@6
In the Audacity preferences where you provide the path to libavformat, make sure you’re pointing to the version 6 library.
/usr/local/Cellar/ffmpeg@6/6.1.1_1/lib
Click okay and close audacity (it will still appear that you have not successfully selected the library). When you open it again it will say something like “FFmpeg Library Version: F(60.16.100),C(60.31.102),U(58.29.100)”
This explains the full situation: https://github.com/audacity/audacity/issues/3747