FfMpeg
Get image width and height
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 barborko-youtube.png
Resize png to ratio 16:9 and fill up the empty space with RGB color (132,33,244) - hex 0x8421F4
ffmpeg -i input.png -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=0x8421F4" output.png
Combine mp3 and image to mp4 file
ffmpeg -loop 1 -i image.png -i audio.mp3 -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest output.mp4
Create the 0.5-second silent audio file
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 0.5 silence.mp3
Add each mp3 file that starts with 0 to txt and add silence after each one:
for file in 0*.mp3; do echo "file '$file'" >> file_list.txt; echo "file 'silence.mp3'" >> file_list.txt; done
Concat the audio files:
ffmpeg -f concat -safe 0 -i file_list.txt -acodec libmp3lame -b:a 192k output.mp3
Trim longer background audio to fit the foreground:
ffmpeg -i background.mp3 -t $(ffmpeg -i foreground.mp3 2>&1 | grep Duration | awk '{print $2}' | tr -d ,) trimmed_background.mp3
Overlay the audio files:
ffmpeg -i foreground.mp3 -i trimmed_background.mp3 -filter_complex "[1:a]volume=0.3[a1];[0:a][a1]amix=inputs=2:duration=first" output.mp3
Loop background audio if it's shorter than the foreground:
ffmpeg -i foreground.mp3 -i background.mp3 -filter_complex "[1:a]aloop=loop=-1:size=2e+9[a1];[a1]atrim=0:$(ffprobe -i foreground.mp3 -show_entries format=duration -v quiet -of csv=p=0)[b1];[b1]volume=0.2[bg];[0:a][bg]amix=inputs=2:duration=first" output.mp3