在阅读这个线程之后:streaming m3u8 file with opencv
我已经实现了这个代码来流一个实时照相机:
import m3u8
import cv2
import subprocess as sp
import numpy as np
VIDEO_URL = r'https://5e0da72d486c5.streamlock.net:8443/ayalon/HaHalacha.stream/playlist.m3u8'
FFMPEG_BIN = r"C:\ffmpeg-n4.4-latest-win64-lgpl-4.4\bin\ffmpeg.exe"
# cv2.namedWindow("GoPro", cv2.CV_WINDOW_AUTOSIZE)
pipe = sp.Popen([FFMPEG_BIN, "-i", VIDEO_URL,
"-loglevel", "quiet", # no text output
"-an", # disable audio
"-f", "image2pipe",
"-pix_fmt", "bgr24",
"-vcodec", "rawvideo", "-"],
stdin=sp.PIPE, stdout=sp.PIPE)
while True:
raw_image = pipe.stdout.read(432 * 240 * 3) # read 432*240*3 bytes (= 1 frame)
image = np.frombuffer(raw_image) # np.fromstring(raw_image, dtype='uint8').reshape((240, 432, 3))
cv2.imshow("Stream", image)
if cv2.waitKey(5) == 27:
break
cv2.destroyAllWindows()
但我看到的图像只是白噪音。我遗漏了什么?Thx
发布于 2022-04-28 08:19:35
让您知道,当您在这个网站上下载库时:
https://github.com/BtbN/FFmpeg-Builds/releases
那些以他们的名字分享的人意味着他们已经建好了
那些不意味着你们必须自己建造它们的人
试着使用预构建的
https://stackoverflow.com/questions/72041895
复制相似问题