大华摄像头
大华摄像头提供了接口直接访问抓图,每秒钟一张
http://192.168.xx.xx/cgi-bin/snapshot.cgi
在代码中去抓图
import requests
from requests.auth import HTTPDigestAuth
response = requests.get(
"http://<摄像头IP>/cgi-bin/snapshot.cgi",
auth=HTTPDigestAuth("admin", "摄像头密码")
)
with open("snapshot.jpg", "wb") as f:
f.write(response.content)
海康摄像头
我使用 ffmpeg进行抓图
ffmpeg -i rtsp://username:password@192.168.2.75:554/h264/ch1/main/av_stream -y -f mjpeg -t 0.001 -s 1280x720 test.jpg