I've been trying to implement with python 2.7 a function to pass a command to cli to convert videos with ffmpeg, until now works almost great, the problem is that sometimes throws IOError: [Errno 32] Broken pipe and I'm not shure why it's happening. Can you help me with this?

This is my function to pass a command to the cli:

def _cli(cmd):
# TODO validate function
errors = False
...