python - Stream video from Raspberry pi camera to Android app -
i'm writing project using raspberry pi , mobile (android). have problem send data camera rpi android app.
i'm using library picamera on python: https://picamera.readthedocs.io/en/release-1.13/recipes1.html#recording-to-a-network-stream .
my actual code on rpi looks this:
import socket import time import picamera camera = picamera.picamera() camera.resolution = (640, 480) camera.framerate = 24 server_socket = socket.socket() server_socket.bind(('0.0.0.0', 8000)) server_socket.listen(0) # accept single connection , make file-like object out of connection = server_socket.accept()[0].makefile('wb') try: camera.start_recording(connection, format='h264') camera.wait_recording(60) camera.stop_recording() finally: connection.close() server_socket.close()
to receive stream can use: tcp/h264://x.x.x.x:8000 . works on pc when used vlc.
on android try use videoview or exoplayer, problem uri because, android can't parse tcp/h264 protocol.
when try stream using vlc:
raspivid -o - -t 99999 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8000}' :demux=h264
it works on android if pass url prefix http:// not program on python.
it seems me have 2 ways.
- on python use different way stream video output.
- somehow handle protocol tcp/h264 (probably used socket , independently parse stream bytes video). possible: https://github.com/shawnbaker/rpicameraviewer looking better (not low level) solution.
Comments
Post a Comment