[Python] Passing two named pipes as input to ffmpeg using python

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página