0

I have two data streams, each representing a rabbitmq subscriber. Inside audio and video streams, data is in the form of bytes. Something like:

vp = VideoProcess()
ap = AudioProcess()


async def receive_video_data(message: IncomingMessage):
    async with message.process():
        await vp.process(frame=message.body)


async def receive_audio_data(message: IncomingMessage):
    async with message.process():
        await ap.process(packet=message.body)


I wanted to take this data from each stream and put it in the ffmpeg stream, which would open the port on the service. So that I can broadcast this data to other subsystems in the form of an ffmpeg stream (for example, to broadcast audio and video to my html page). Can you tell me what are the options for this task?

process = sp.Popen(
    shlex.split(
        f"ffmpeg -i ...."
    ))

user5285766
  • 109
  • 2
  • 10
  • Are you on non-Windows OS? If so, use multiple pipes: `-f ... -i pipe:3 -f ... -i pipe:4` – kesh Jun 02 '22 at 13:18
  • This code is running inside docker container and it is ubuntu. I can't figure out how I can upload data inside the process with ffmpeg. It would be possible through stdout and stderr as I do it in another process when reading data. Now I want to pass them on from python, but I can’t find examples on the Internet to do this – user5285766 Jun 02 '22 at 15:24
  • With Linux, you should be able to. Along with the [pipe protocol](http://ffmpeg.org/ffmpeg-protocols.html#pipe) in FFmpeg as I mentioned above, [this link](https://stackoverflow.com/questions/28840575) should help you setting up additional named pipes in Python. Unfortunately, I'm in Windows, so I cannot demo a use case for you. Good luck. – kesh Jun 02 '22 at 16:06
  • http://ffmpeg.org/ffmpeg-protocols.html#pipe The documentation on ffmpeg enlightened me, but nevertheless I see there the possibility to upload data from only one stream (either audio or video) using stdin. How to me to throw the data in process from two flows? Audio and video ? Or have I missed something? Thanks for your answers. – user5285766 Jun 02 '22 at 22:55
  • I think you missed my first post above ^^;. Anyway, for example, `ffmpeg -f h264 -i pipe:3 -f pcm_s16le -i pipe:4 ...` let you input 2 piped streams via `pass_fds` argument of `Popen`. First one being raw h.264 stream and the second one raw 16-bit signed PCM audio stream. You aren't using `stdin` in this case (ofc you can if you wish to do so) – kesh Jun 03 '22 at 00:12

0 Answers0