I came across a need for this when I wanted to upload an audio recording of coyotes to Facebook. FB doesn’t allow simple audio files. Nor does it allow a video file with an audio track but no video track.
I picked up the needed ffmpeg command online and adapted it to my need.
ffmpeg -loop 1 -i imagefile.jpg -i audiofile.m4a -c:a copy -c:v libx264 -shortest result.mp4
The image file should be a reasonable size, not some 3k x 4k hi res image, otherwise the resulting file will be too big. I have used a jpeg file but not tried png although I would expect that to work.
The audio file also can be in any form that ffmpeg supports but m4a works well.
Output to x264 works well for compressing the static image. And FB is happy with it.
‘-shortest’ causes it to stop on the shortest of the input files. ‘-loop 1’ causes the image to be looped for the duration of the audio file. The audio file will always be the ‘shortest’ because it is finite whereas the image is looped.