Forums

Webcam streaming through Flask

Hi, I'm trying to deploy a python application that, through Flask, streams live video to clients using Motion JPEG, which just sends JPEG frames successively. The code (found here http://www.chioka.in/python-live-video-streaming-example) works fine locally. My target is to create a sort of IPcamera, so I would like to access to video directly on the web, that's why I tried the deployment on PA. The web page just displays the header, but not the video (broken image icon only). This the error I get: 2016-10-31 23:03:22,576 :Error running WSGI application Traceback (most recent call last): File "/bin/user_wsgi_wrapper.py", line 155, in call for response in app_iterator: File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 703, in next return self._next() File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 81, in _iter_encoded for item in iterable: File "./flask_app.py", line 27, in gen frame = camera.get_frame() File "./camera.py", line 21, in get_frame ret, jpeg = cv2.imencode('.jpg', image) error: /io/opencv/modules/imgcodecs/src/grfmt_base.cpp:139: error: (-10) Raw image encoder error: Empty JPEG image (DNL not supported) in function throwOnEror

I'm running this on Windows Vista. Any idea? :)

Regards Luca

There is no camera connected to the PythonAnywhere servers and it there was, it would probably just be showing a very boring view of rows and rows of computers in a bunker underground.

Obviously I'm not interested into servers watching :D The script, when run locally, uses the camera of my laptop. Is there a way to stream the frames captured from my laptop camera to a webpage outside my LAN?

You could probably work out some way to send the stream to PythonAnywhere and then have it serve the stream from there, but I have no idea how "real time" that would be or what sort of challenges you might face on the way.