Reputation: 151
I have a ffmpeg pipeline in a shell script that is launched as a subprocess in Python. For some reason, when Python launches the script, my video streams perfectly and then freezes at about six minutes every time. After it freezes, if I tried to run the script manually, it gives me this error:
Invalid MIT-MAGIC-COOKIE-1 keyxcb_connection_has_error() returned true Failed to symlink /root/.pulse/65f3ded611649c6dcf9ebae20000046d-runtime to /tmp/pulse-PKdhtXMmr18n: Input/output error [alsa @ 0x4b2f0] cannot open audio device hw:0,0 (Device or resource busy) hw:0,0: Input/output error
However, if I restart and run the script manually, the audio & video will play fine indefinitely.
Does anyone know why this is happening? Thanks.
Here is my pipline.sh file:
sudo ffmpeg -f video4linux2 -video_size 640x480 -framerate 30 -input_format yuyv422 -i /dev/video7 -f alsa -i hw:0,0 -map 0:0 -map 1:0 -b:v 120k -bufsize 120k -vcodec libx264 -preset ultrafast -crf 28 -acodec aac -strict -2 -f flv -metadata streamName= StreamName tcp://71.192.1.22
And this is the subprocess I'm using in Python:
subprocess.Popen("sudo ./ffmpeg_script.sh", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Upvotes: 3
Views: 1677
Reputation: 30947
My guess: the script isn't draining the stdout pipe quickly enough, and it's filling up with debugging output to the point that ffmpeg's stdout runs out of buffer space and it freezes.
Upvotes: 4