Jevy Wang's Blog

Read H264 livestream using ffmpeg and cv2

Got a Solar WiFi IP camera from Wireless Solar IP67 Security Camera System Outdoor Home Cam 1080P 2MP

Wondering to capture video or images from the camera using script/program.

ffmpeg -re -i "http://host ip:81/livestream.cgi?user=admin&pwd=&streamid=0" -c copy -f mpegts test.mp4

ffmpeg -i "http://host ip:81/livestream.cgi?user=admin&pwd=a123&streamid=0" -c copy -f mpegts -ss 5 -frames:v 5 testt.png

FFMPEG is not portable, another way of using cv2 to capture a picture:
(ref Not able to play .h264 video on OpenCV?)

cap = cv2.VideoCapture('http://host:81/livestream.cgi?user=admin&pwd=&streamid=0')
        while(cap.isOpened()):
            ret, frame = cap.read()
            # write to local file
            cv2.imwrite("capture.png",frame)
            # create memory file object save to AWS S3
            #img_data = io.BytesIO(cv2.imencode('.png', frame)[1])
            break
        cap.release()

专题:

本文发表于 2020-03-12,最后修改于 2020-03-12。

本站永久域名jevy.wang,也可搜索「 Jevy Wang's Blog 」找到我。

期待关注我的 知乎专栏 ,查看最近的文章和动态。


上一篇 « About Me 下一篇 » Package AWS Lambda function

赞赏支持

请我吃胡萝卜 =^_^=

i ali

支付宝

i wechat

微信

推荐阅读

Big Image