How to take a full-resolution JPEG snapshot from a Hi351x IP camera via HTTP

Las cámaras de la familia Hi351x (Hi3510/Hi3516 y SoCs compatibles, stack ONVIF hfonvif/1.0 — las que se identifican como IPCamera y streamean vía rtsp://<ip>:554/stream_0/stream_1) pueden servir un JPEG fijo a resolución completa por HTTP plano — sin decodificar el stream RTSP tú mismo.

La URL del snapshot

snapshot.sh
curl -o snapshot.jpg "http://10.91.1.207/action/cgi_images"

Esto devuelve Content-Type: image/jpeg a la resolución del main-stream de la cámara (p.ej. 1920×1080). Verificado funcionando en el firmware 22.010.30.6_MAIN_V44.

Si el endpoint devuelve un error JSON como {"code":208,...} en otras rutas, fíjate en que la ruta correcta es /action/cgi_images — no /snap.jpg, /webcapture.jpg, ni /tmpfs/auto.jpg (esas dan 404 en esta familia).

Descubrirla vía ONVIF (puerto 8080)

La misma URI es lo que anuncia GetSnapshotUri de ONVIF. Útil para confirmar el endpoint en un firmware distinto o cuando la ruta difiere:

onvif_snapshot_uri.sh
# 1) Find the Media service XAddr
curl -s -X POST -H "Content-Type: application/soap+xml" \
  --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body><GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"><Category>Media</Category></GetCapabilities></s:Body></s:Envelope>' \
  http://10.91.1.207:8080/onvif/device_service | grep -o '<tt:XAddr>[^<]*'

# 2) List profiles → take the profile token (e.g. profile0)
curl -s -X POST -H "Content-Type: application/soap+xml" \
  --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body><GetProfiles xmlns="http://www.onvif.org/ver10/media/wsdl"/></s:Body></s:Envelope>' \
  http://10.91.1.207:8080/onvif/Media | grep -o 'token="profile[0-9]*"'

# 3) GetSnapshotUri
curl -s -X POST -H "Content-Type: application/soap+xml" \
  --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body><GetSnapshotUri xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>profile0</ProfileToken></GetSnapshotUri></s:Body></s:Envelope>' \
  http://10.91.1.207:8080/onvif/Media | grep -o '<tt:Uri>[^<]*'

Salida esperada:

output.txt
http://10.91.1.207:80/action/cgi_images

Ejemplo en Python

snapshot.py
import urllib.request

def take_snapshot(ip, out_path="snapshot.jpg", timeout=10):
    url = f"http://{ip}/action/cgi_images"
    data = urllib.request.urlopen(url, timeout=timeout).read()
    if not data.startswith(b"\xff\xd8"):
        raise ValueError(f"not a JPEG ({len(data)} bytes)")
    with open(out_path, "wb") as f:
        f.write(data)
    return out_path

take_snapshot("10.91.1.207")

Configuración de la cámara

Para configurar los streams, codificadores, resolución, GOP etc. de la cámara, usa Hi351x-Camera-CLI — una herramienta CLI que escanea la red buscando estas cámaras, vuelca su configuración completa y aplica cambios (setVencConf, etc.) en dispositivos individuales o subredes enteras.


Echa un vistazo a artículos similares por categoría: IP-Cameras