Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup a USB camera on RPi #395

Open
shekarpathi opened this issue Dec 7, 2021 · 1 comment
Open

How to setup a USB camera on RPi #395

shekarpathi opened this issue Dec 7, 2021 · 1 comment

Comments

@shekarpathi
Copy link

I have a Pi2 running the latest Bullseye OS.
I have two USB cameras attached to this PI. How do I setup/configure camera.py to make it stream so that I can watch the camera feed from my iPhone using Homekit
I have installed ffmpeg also.

@fwebcc
Copy link

fwebcc commented Dec 12, 2021

def get_bridge(driver):
bridge = Bridge(driver, 'Bridge')
size=len(mqtt_conf["list"])
for i in range(0,size,1):
if str(mqtt_conf["list"][int(i)]["mode"])=='camera':
v_type=mqtt_conf["list"][int(i)]["cmdoff"]
v_code=mqtt_conf["list"][int(i)]["Subscribe"]
v_ip=mqtt_conf["list"][int(i)]["cmdon"]
v_add=mqtt_conf["list"][int(i)]["Publish"]
options['start_stream_cmd']=v_ip
options['start_stream_cmd']=(
'ffmpeg -re '+v_type+' -i '+v_add+' -threads 4 '
'-vcodec '+v_code+' -an -r {fps} '
'-f rawvideo -tune zerolatency '
'-vf scale={width}x{height} -b:v {v_max_bitrate}k -bufsize {v_max_bitrate}k '
'-payload_type 99 -ssrc {v_ssrc} -f rtp '
'-srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params {v_srtp_key} '
'srtp://{address}:{v_port}?rtcpport={v_port}&'
'localrtcpport={v_port}&pkt_size=1378')
acc = HAPCamera(options, driver, mqtt_conf["list"][int(i)]["title"])
bridge.add_accessory(acc)
return bridge

class HAPCamera(camera.Camera):
def get_snapshot(self, image_size):
with open(os.path.join('./snapshot.jpg'), 'rb') as fp:
return fp.read()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants