ffmpeg 处理时中断流

Анд*_*рей 5 python video ffmpeg stream

我从服务器接收视频(如原始流),然后通过管道将其传送到 ffmpeg,但如果下载中断几秒钟,则处理失败并显示消息: \xe2\x80\x98Invalid NAL unit size\xe2\x80\x99 和 \xe2\ x80\x98access\xe2\x80\x99 中缺少图片。

\n

我想做一些类似缓冲区的事情,但我不知道如何在从服务器接收字节并从正确的位置继续处理时暂停 ffmpeg 处理。

\n

我的 ffmpeg 命令:

\n
def writer():\n    for chunk in iter(partial(stream.read, 1024), b''):\n        process.stdin.write(chunk)\n\nprocess = subprocess.Popen(('ffmpeg -i pipe: -f flv -codec copy -listen 1 '\n                            '-flvflags no_duration_filesize '\n                            'http://127.0.0.1:8080 -re '), stdin=subprocess.PIPE)\n\n
Run Code Online (Sandbox Code Playgroud)\n