【发布时间】:2020-05-11 11:03:40
【问题描述】:
我正在尝试处理实时 hlsv 流,从中提取每 100 帧,然后使用 openCV 对其进行处理。
目前我的代码如下所示:
pipe = subprocess.Popen([FFMPEG_BIN, "-i", src,
"-loglevel", "quiet",
"-an",
"-f", "image2pipe",
"-pix_fmt", "bgr24",
"-vcodec", "rawvideo", "-"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
while True:
raw_image = pipe.stdout.read(WIDTH * HEIGHT * 3)
if frame_counter > 100:
frame_counter = 0
process_frame(raw_image)
frame_counter += 1
读取所有帧并转储其中的 99% 似乎效率低下,并导致我遇到管道缓冲区问题(至少我怀疑)。
是否可以跳过 FFMPEG 中的帧,以便每 100 帧将进入标准输出?
【问题讨论】:
标签: python ffmpeg subprocess