gpt4 book ai didi

python - 为什么我的 ffmpeg 流子进程在 6 分钟时卡住?

转载 作者:行者123 更新时间:2023-12-04 22:56:19 33 4
gpt4 key购买 nike

我在 shell 脚本中有一个 ffmpeg 管道,它在 Python 中作为子进程启动。出于某种原因,当 Python 启动脚本时,我的视频完美流式传输,然后每次卡住大约六分钟。卡住后,如果我尝试手动运行脚本,它会给我这个错误:

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



但是,如果我手动重新启动并运行脚本,音频和视频将无限期地正常播放。

有谁知道为什么会这样?谢谢。

这是我的 pipline.sh 文件:
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

这是我在 Python 中使用的子进程:
subprocess.Popen("sudo ./ffmpeg_script.sh", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

最佳答案

我的猜测:脚本没有足够快地耗尽标准输出管道,并且它充满了调试输出,以至于 ffmpeg 的标准输出用完缓冲区空间并卡住。

关于python - 为什么我的 ffmpeg 流子进程在 6 分钟时卡住?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26898698/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com