Hey all,
Just wondering what your experience has been with URL requests for IP camera.
I have the following with a HikVision IP camera.
Streaming
rtsp://user:password@192.168.8.100/Streaming/channels/102/httpPreview
→ Works fine in VLC and Mycodo, although I wish I knew how to reduce the resolution to have a more fluid image.
Still capture
http://user:password@192.168.8.100:80/ISAPI/Streaming/channels/102/picture
→ Works fine in this python script:
import pycurl
from io import BytesIO
b_obj = BytesIO()
crl = pycurl.Curl()
#Set URL value
crl.setopt(crl.URL,"http://user:password@192.168.8.100:80/ISAPI/Streaming/channels/102/picture")
#write bytes that are utf-8 encoded
with open('/home/pi/test.jpg','wb') as f:
crl.setopt(crl.WRITEFUNCTION, f.write)
#Perform a file transfer
crl.perform()
#end curl session
crl.close()
# get the content stored in the bytesIO object (in byte characters)
get_body = b_obj.getvalue()
print('Output of get request: \n%s' % get_body.decode('utf8'))
→ Doesn’t work in Mycodo > Cameras > urllib:
Error: Could not acquire image.
- Is there a log where I can see the details of the issue with the still capture?
- Would using URL requests work better? If so, can anyone recommend the right headers in json (the authentication method is basic or digest)?
PS. Adding the relevant mycodo log. It seems to be a networking-related issue based on some googling…
Mar 09 16:04:20 hydropi python[5597]: 2023-03-09 16:04:18,585 <urlopen error [Errno -2] Name or service not known>
Mar 09 16:04:20 hydropi python[5597]: Traceback (most recent call last):
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/urllib/request.py", line 1346, in do_open
Mar 09 16:04:20 hydropi python[5597]: h.request(req.get_method(), req.selector, req.data, headers,
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 1255, in request
Mar 09 16:04:20 hydropi python[5597]: self._send_request(method, url, body, headers, encode_chunked)
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
Mar 09 16:04:20 hydropi python[5597]: self.endheaders(body, encode_chunked=encode_chunked)
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
Mar 09 16:04:20 hydropi python[5597]: self._send_output(message_body, encode_chunked=encode_chunked)
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
Mar 09 16:04:20 hydropi python[5597]: self.send(msg)
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 950, in send
Mar 09 16:04:20 hydropi python[5597]: self.connect()
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/http/client.py", line 921, in connect
Mar 09 16:04:20 hydropi python[5597]: self.sock = self._create_connection(
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/socket.py", line 822, in create_connection
Mar 09 16:04:20 hydropi python[5597]: for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Mar 09 16:04:20 hydropi python[5597]: File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo
Mar 09 16:04:20 hydropi python[5597]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
Mar 09 16:04:20 hydropi python[5597]: socket.gaierror: [Errno -2] Name or service not known