(03-13-2017 07:50 PM)jolouis Wrote: 2) Wire up a DSS key to launch an XML browser to the server, and have the server run a script that grabs a single frame from the camera, re-sizes it to what the phone expects, and then displays it. Not ideal in any way, but better than nothing.
3) Give up [...]
That's almost exactly how we tried to do it.
Also the HD camera would not let you grab single jpeg frames over http, but insists in making you use rtsp (actually makes sense regarding bandwith), so we grabbed a single frame from the rtsp stream using a Python script on a Windows VM that calls ffmpeg...
It turned out that the whole process from pressing the DSS button to actually seeing the picture would take almost 10 seconds, and most of that was not caused by ffmpeg having to connect to the camera first (also it didn't look nice as the screen would flash multiple times)
So we abandoned this, however just in case the XML might be useful for someone, here's the script I wrote back then:
Code:
from http.server import HTTPServer, BaseHTTPRequestHandler
import string, subprocess
rtspURL = "rtsp://CAMERA_HOST:554/ucast/11"
yealink_xml = """<?xml version="1.0" encoding="ISO-8859-1"?>
<YealinkIPPhoneImageScreen Beep="no" Timeout="5" LockIn="no" mode="regular">
<Image verticalAlign="middle" horizontalAlign="middle">HOST_WHERE_THIS_RUNS/doorcam.jpg</Image>
</YealinkIPPhoneImageScreen>"""
class DoorCamHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
if(self.path == "/doorcam.jpg"):
resultimage = subprocess.check_output("ffmpeg.exe -i " + rtspURL + " -f image2 -vframes 1 -")
self.send_response(200)
self.send_header('Content-type','image/jpg')
self.send_header('Connection','close')
self.send_header('Content-Length', len(resultimage))
self.end_headers()
self.wfile.write(resultimage);
else:
self.send_response(200)
self.send_header('Content-type','text/xml')
self.send_header('Connection','close')
self.send_header('Content-Length', len(yealink_xml.encode()))
self.end_headers()
self.wfile.write(yealink_xml.encode());
print("starting http server")
server_address = ('', 80)
# todo: ThreadingMixIn
httpd = HTTPServer(server_address, DoorCamHTTPRequestHandler)
httpd.serve_forever()
192.168.0.120 being the Windows machine this ran on, .149 the camera.
I think you should add some resize / crop depending on the resolution of your camera image.
// edit: Akismet apparently did not allow me to include http links