benbusby / piro

A Raspberry Pi security camera rover
MIT License
100 stars 17 forks source link

Can get 1 second of video and then dead? #11

Closed WillChilcutt closed 5 years ago

WillChilcutt commented 5 years ago

Hi,

Followed your tutorial but when I connect to my RazTot via Dataplicity I only see around 1-2 seconds of video before the feed dies and I see the following getting spammed in my terminal (on my pi):

[ERR] [ice.c:janus_ice_outgoing_traffic_handle:4118] [5714788999919634] ... only sent -1 bytes?

Any idea of what would cause it to work for a split second and then just stop suddenly? If I watch my "wormhole" page even after the video cuts out I can see the steamrate going up and down, but no video. I tried it in Chrome and Safari on my Mac and both times I see that above error on the pi almost immediately.

Thanks!

benbusby commented 5 years ago

I've seen this error before when attempting to stream higher quality video with limited bandwidth, and it seems to be an issue that gets brought up a lot in the Janus Gateway google group. It's most likely throughput related, not MTU, so your best bet is to tweak the settings of the gstreamer pipeline in utils/stream.sh.

If you reduce the bitrate (i.e. from 3000000 to 1000000) and the keyframe-interval / framerate (i.e. from 20 to maybe 15 or 10) and see an improvement, then it's likely just a bandwidth issue. You could also try removing the split udp sink and just do a single stream to see if that helps, but that would remove the ability to record streams via the web app.

Unfortunately there's not a "one size fits all" pipeline to use since bandwidth can vary so much, but with a little tweaking you should be able to get it to a reasonable point with no freezing.

Here's a couple of modified pipelines you can copy paste, try out and see if it works for you (and feel free to adjust the parameters as needed).

Single udpsink

gst-launch-1.0 -v rpicamsrc vflip=true hflip=true preview=false bitrate=1000000 keyframe-interval=10 ! video/x-h264, framerate=10/1 ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=8004

Forked udpsink (allows for recording)

gst-launch-1.0 -v rpicamsrc vflip=true hflip=true preview=false bitrate=1000000 keyframe-interval=10 ! video/x-h264, framerate=10/1 ! h264parse ! rtph264pay config-interval=1 pt=96 ! multiudpsink clients=127.0.0.1:8004,127.0.0.1:8005

Let me know if one of those (or a different one) ends up working for you.

benbusby commented 5 years ago

Any updates?

WillChilcutt commented 5 years ago

Hey Ben,

Thanks for responding so quickly and I'm sorry I haven't followed up. Unfortunately I'm building the project with my daughter and we haven't had time to get back to the project. Hoping to work on the project again this coming weekend. I'll let you know the outcome.

Thanks for your time!

benbusby commented 5 years ago

No worries (and no rush)! Just wanted to check in and see if there was anything else I could help with.

WillChilcutt commented 5 years ago

Hey Ben,

Got a chance to try out your changes and they worked perfectly! Thank you for your help and sorry for the delayed resolution!

I'll let you close this issue out when you're ready.

Thanks again!

benbusby commented 5 years ago

Awesome! I’m glad the changes worked for you. Thanks for taking interest in the project and building one!