I have two av streams, one video and one audio, i'm trying to pipe both as inputs to ffmpeg
os.mkfifo(VIDEO_PIPE_NAME)
os.mkfifo(AUDIO_PIPE_NAME)
ffmpeg_process = subprocess.Popen([ "ffmpeg", "-i", VIDEO_PIPE_NAME, "-i", AUDIO_PIPE_NAME,
"-listen", "1", "-c:v", "copy", "-c:a", "copy", "-f", "mp4", "-movflags",
"frag_keyframe+empty_moov", "http://0.0.0.0:8081"], stdin=subprocess.PIPE)
pipe_video = open(VIDEO_PIPE_NAME,'wb')
pipe_audio = open(AUDIO_PIPE_NAME,'wb') #Code stuck here
The code stuck on pipe_audio = open(AUDIO_PIPE_NAME,'wb')
line, I'm guessing it is happening because ffmpeg only reads the first/video input and ignore the second/audio input so the pipe is not being read.
If I use only pipe_video
and removing -i AUDIO_PIPE_NAME
flag from ffmpeg everything works fine, but i only get the video without the audio.
I can confirm chrslg's comment under the OP. Placing each pipe's open()
call in its own write thread should resolve your issue.
I'm nearing to release a new version of ffmpegio
to introduce this exact feature, and it works well.