I am trying to stream Raspberry Pi camera, and for security reasons I'm tunneling my server through a secured server even though the client is on the same LAN. However, this resulted in horrible latency. I'm trying now to stream the video over the LAN instead of through the server. I know that browsers only allow HTTP connections over HTTPS servers only on passive elements, such as .
My server is saving the image as a local jpeg file encoded as base64:
camera = cv2.VideoCapture(0)
grabbed, frame = camera.read()
frame = cv2.resize(frame, (320, 240))
buffer = cv2.imencode('.jpg', frame)[1]
buffer = base64.b64encode(buffer)
buffer.decode('utf-8')
with open(ROOT + '/static/image.jpeg', mode='wb+') as image:
image.write(buffer)
my client has an image tag, and a simple script to request the file saved:
<img id='img'>
<script>
setInterval(function() {
var myImageElement = document.getElementById('img');
myImageElement.src = 'data:image/jpg;base64,http://10.0.0.35:8000/static/image.jpg?rand=' + Math.random();
}, 500);
</script>
The result is a constant stream of console errors such as:
data:image/jpg;charset=utf-8;base64,http://10.0.0.35:8000/static/image.jpg?rand=0.7520646586573345:1 GET data:image/jpg;charset=utf-8;base64,http://10.0.0.35:8000/static/image.jpg?rand=0.7520646586573345 net::ERR_INVALID_URL
I have checked that the image is accessible (entered http://10.0.0.35:8000/static/image.jpg in my broswer, and haven't gotten any errors) I have also checked that the file is a base64 jpeg using an online tool. I have looked at this question but nothing there worked, I can't understand why am I getting this error, and how to solve it. Can someone please direct me in the right direction?