Is it possible to grab a single image from an IP Camera stream (ONVIF)?

I have a web application that needs to grab an image from an IP camera within the network. is this possible using PHP? or at least JS? Just need the web application to grab and save images off the IP camera. I have been able to do this using WEBCAMS (thru USB webcam) but not sure how to do this using an actual IP camera. Would love it also if there's an already available script (Free or paid) to do this..

Any help would really be appreciated!

PS camera also has RSTP support... if that makes it easier to achieve the same outcome...

2 answers

  • answered 2018-01-14 10:05 user3433200

    If your camera has FTP support and you can FTP images when desired, then you could try the IP Camera FTP and remote viewing service I'm currently developing:

    Run the demos or create an account at

    This service has the ability to share the latest image from each camera via a web address (enabled from settings -> share) e.g. For bird feeder demo account:

    You will also have a historical record of images which may be of interest.

    Many advantages over a simple FTP server and currently free while in development. If the service proves viable and goes commercial subscription will be priced comparable to the electricty cost of running a recorder 24x7

  • answered 2018-01-14 11:01 Aleksandar

    Easier solution might be to switch to python and opencv. It's easy to get any stream from IP camera, and with help of opencv You can save to video or series of images in less than 3 minutes.

    import cv2
    import time
    cap = cv2.VideoCapture(stream_url) # it can be rtsp or http stream
    ret, frame =
    while ret:
        cv2.imwrite('images/{}.jpg'.format(time.time()), frame)
        ret, frame =

    Also, look for camera API, many IP cameras have address of single snapshot, so you can pull that and save it:

    import numpy as np
    import cv2
    import urllib
    resp = urllib.urlopen(url)
    image = np.asarray(bytearray(, dtype="uint8")
    image = cv2.imdecode(image, cv2.IMREAD_COLOR)
    # image is in memory, we can save it, send it etc...

    And finally, in most cases, IP camera have mjpeg stream that can be embedded directly inside img html tag <img href='http://ip_address/video.mjpg' /> as an example