用几个出口模拟管道。(Emulate pipe with several outlets. Is python fast enough for this?)

我从ffmpeg输入了字节。 我想将此输出发送到其他几个ffmpeg进程。 因为我不能使用Unix Pipe,Socket,..为此(或者我可以?)我使用python作为管道的接收端。 然后子程序将接收的数据复制到所有先前“已注册”的插座。

感觉不对劲!

具体来说,我觉得这意味着大量的内存复制。 它现在有效。 但我真的很想知道这样做的“正确方法”。

def writeData(self,data): """Write 'data' to all outputs""" if len(self.outlets) > 0: for outlet in self.outlets: outlet.writeData(data) else: self.logger.warn("Received data but no outlets registred (yet?)")

I have input bytes from ffmpeg. I'd like to send this output to several other ffmpeg processes. Since I can't use a Unix Pipe, Socket,.. for this (or can I?) I'm using python as the receiving end of the pipe. A subroutine then copies the received data to all previously "registered" outlets.

It feels wrong!

Specifically I have the feeling that this means a lot of memory copying. It works right now. But I'd seriously love to head about "the right way" of doing this.

def writeData(self,data): """Write 'data' to all outputs""" if len(self.outlets) > 0: for outlet in self.outlets: outlet.writeData(data) else: self.logger.warn("Received data but no outlets registred (yet?)")

最满意答案

这可能足够快,特别是现在CPU的速度与压缩视频数据的相对较低带宽相比。

与往常一样,您必须对解决方案进行测试和基准测试,以确保其满足您的性能要求。

This is likely to be fast enough, especially with the speed of CPUs now compared to the relatively lower bandwidth of compressed video data.

As always, you will have to test and benchmark your solution to ensure that it meets your performance requirements.

用几个出口模拟管道。(Emulate pipe with several outlets. Is python fast enough for this?)

我从ffmpeg输入了字节。 我想将此输出发送到其他几个ffmpeg进程。 因为我不能使用Unix Pipe,Socket,..为此(或者我可以?)我使用python作为管道的接收端。 然后子程序将接收的数据复制到所有先前“已注册”的插座。

感觉不对劲!

具体来说,我觉得这意味着大量的内存复制。 它现在有效。 但我真的很想知道这样做的“正确方法”。

def writeData(self,data): """Write 'data' to all outputs""" if len(self.outlets) > 0: for outlet in self.outlets: outlet.writeData(data) else: self.logger.warn("Received data but no outlets registred (yet?)")

I have input bytes from ffmpeg. I'd like to send this output to several other ffmpeg processes. Since I can't use a Unix Pipe, Socket,.. for this (or can I?) I'm using python as the receiving end of the pipe. A subroutine then copies the received data to all previously "registered" outlets.

It feels wrong!

Specifically I have the feeling that this means a lot of memory copying. It works right now. But I'd seriously love to head about "the right way" of doing this.

def writeData(self,data): """Write 'data' to all outputs""" if len(self.outlets) > 0: for outlet in self.outlets: outlet.writeData(data) else: self.logger.warn("Received data but no outlets registred (yet?)")

最满意答案

这可能足够快,特别是现在CPU的速度与压缩视频数据的相对较低带宽相比。

与往常一样,您必须对解决方案进行测试和基准测试,以确保其满足您的性能要求。

This is likely to be fast enough, especially with the speed of CPUs now compared to the relatively lower bandwidth of compressed video data.

As always, you will have to test and benchmark your solution to ensure that it meets your performance requirements.