Newest ffmpeg v4.4 is having issues with Blender 2.92 (animation audio is not rendered with video)

The newest Blender package in the Arch Linux repositories changed its ffmpeg dependency from v4.3 to v4.4 and now Blender fails to render audio when using ffmpeg and I don’t know what other stuff got broken too.

It might be worth checking out if it’s a Blender or ffmpeg bug…

I can reproduce this on my Gentoo machine as well.

I did a patch a while back to remove use of deprecated ffmpeg functions and update to the new API:

It doesn’t apply to master, but if I roll back to a commit from the 8th of March (b1ef55abdbb9f47712049748ccf65d009c059160),
then it now prints an error message instead of failing silently:
Can't send audio frame: Invalid argument

It works with ffmpeg 4.3.2 but the latest 4.4 commit still fails, so if this is an ffmpeg issue, then they have not fixed it yet.
I also tried the ffmpeg master branch but blender will need more ffmpeg code cleanup as they have further enforced how they want you to use their API by declaring a few built in variables const.
(This breaks both our ffmpeg writer functions and the Audaspace lib we use for sound playback)

To figure out why it fails, we probably need to do a debug build of ffmpeg and blender and step through the code to figure out what the “invalid argument” is.
(I might be able to do this on monday, we’ll see)

Found the issue!

In source/blender/blenkernel/intern/writeffmpeg.c line 166. We don’t set the number of audio channels the audio frame will have. This fixes that and it now works:
frame->channels = c->channels

I’m guessing that ffmpeg 4.4 added more strict checks so that is why it fails now.

We will probably have a fix for this in blender 2.93 and 3.0