Currently, I am using ffmpeg to start from frames in raw format to generate a video output that is broadcast in OBS.
The problem is that we want to add an audio track to it, that is: each frame will now have its matrix of pixels and its audio.
I don't know exactly how to make ffmpeg take this composite signal or what the best methodology is. Actually I use the stdin of the ffmpeg. I use this code to generate it:
url = "udp://" + udp_address + ":" + str(udp_port)
command = [
'ffmpeg',
'-loglevel',
'error',
'-re',
'-y',
# Input
'-i', '-',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
'-s', str(size[0]) + 'x' + str(size[1]),
# Output
'-b:v', '16M',
'-maxrate', '16M',
'-bufsize', '16M',
'-pix_fmt', 'bgr24',
'-f', 'mpegts', url
]
proc = subprocess.Popen(command, stdin=subprocess.PIPE)
proc.stdin.write(frame.tobytes())
What would be the best methodology to add audio to each frame? Thanks
