python-3.x - ffmpeg Windows 使用来自管道的视频流到 Twitch 仅发送约 100 帧并卡住
问题描述
我尝试在 Windows 上使用 Python 和 ffmpeg 将 rawVideo(一个 numpy 数组)流式传输到 Twitch。但是在~100帧之后我就卡住了。
我的子流程参数:
command = [
"ffmpeg.exe",
'-f', 'rawvideo',
'-vcodec','rawvideo',
'-s', '480x640',
'-pix_fmt', 'rgb24',
'-r', '30',
'-i', '-',
'-vcodec', 'libx264',
'-b:v' , '5M',
'-acodec', 'aac',
'-b:a', '256k',
'-r','30',
'-f', 'flv', 'rtmp://live-fra.twitch.tv/app/%removed for stackoverflow%'
]
[...]
pipe = subprocess.Popen( command, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
发送帧:
frames = 0
frame = np.zeros((480, 640, 3))
#print(pipe,dir(pipe))
while 1:
try:
pipe.stdin.write(frame.tobytes()) # < gets stuck here after ~100 frames
frames += 1
print("frame_send", frames)
except Exception as e:
out, ffmpeg_error = pipe.communicate()
print("error:" , ffmpeg_error , e , out )
break
time.sleep( 1 / 30 )
它只是停留在“pipe.stdin.write(frame.tobytes())”上没有错误
解决方案
推荐阅读
- sql - UNNEST 的订购保证
- tailwind-css - 如何使用 purgeCSS (Tailwindcss) 将属性选择器列入白名单或安全列表?
- python - 为什么在 Python 中扩展嵌套列表也会扩展后续嵌套列表?
- java - 我怎样才能知道类中每个粒子的确切位置?
- java - XA 全球交易 - EtityManager null
- reactjs - 如何在 React JS 的 Javascript 函数中使用参数变量的文字值?
- python - 使用 python 获取 Discord html?
- python - 如何在数据帧上执行 pd.get_dummies() ,同时保持 NA 值到位而不是创建 NA 列?
- informatica - Informatica 间接文件加载 - 生成带有路径的空行
- css - 如何在 CSS 中冻结动画?