piping dynamically data to FFMPEG from FIFO

Good day, everyone.

I am trying to use named FIFO streams to dynamically change the stream data in FFmpeg. I have achieved some success – I can stream video and dynamically set files for playback.

The essence of my goal is to control the output stream by sequentially sending the files that I would like to observe. Here is the code that works:

ffmpeg -re -stream_loop -1 -thread_queue_size 5048 -f mp3 -i audio_fifo -thread_queue_size 5048 -loop 1 -i logo.jpg ...

This creates a stream with a static image, but I can change the audio stream. However, when I try to specify -i image_fifo, the command looks like this:

ffmpeg -re -stream_loop -1 -thread_queue_size 5048 -f mp3 -i audio_fifo -thread_queue_size 5048 -loop 1 -i image_fifo ...

.
The stream works, but without the image. I see that 0 frames have been generated, and this command does not produce an error. The stream is only audio—no video.

I have tried using variations of the command like:

ffmpeg -re -stream_loop -1 -thread_queue_size 5048 -f mp3 -i audio_fifo -thread_queue_size 5048 -loop 1 -f image2pipe -i image_fifo ...

but I have not been able to achieve the desired result.

for adding to fifo i use the python script

def send_file_to_fifo(self, file, fifo_type):
    if os.path.exists(self.settings[fifo_type]):
        if fifo_type not in self.__strm_fifo or self.__strm_fifo[fifo_type] is None:
            self.__strm_fifo[fifo_type] = open(self.settings[fifo_type], 'wb')  # Открытие FIFO в бинарном режиме

        with open(file, 'rb') as file_handle:
            while True:
                #buffer = file_handle.read(1048567)  # 1MB
                buffer = file_handle.read(4096)  # 1MB
                if not buffer:
                    print(f"[INFO] EOF достигнут для {file}")
                    break
                self.__strm_fifo[fifo_type].write(buffer)
                #self.__strm_fifo[fifo_type].flush()

To ensure that the recording is synchronous, I use subprocesses in parallel mode.