-1

Problem :

I want make live stream from my camera attached to Raspberry pi 3 b+, which is connected to home WiFi. Streaming should be over internet. So that any client like Android/ iOS can stream it from anywhere. It is a security camera. There can be multiple Raspberry pi connected to home WiFi.

What I have tried :

1. Raw H.264

I could achieve the same by generating raw H.264 which android app could render. It was perfect. But this needs global IP and port to stream over internet. Problem in this method - I can not assign global IPs to multiple raspberry pi. and it needs port forwarding. Which is not acceptable in automated setup of security camera.

2. Another way

Tried this way too, but this tutorial shows a way to stream locally.

What is needed?

What is preferred way to stream Raspberry Pi camera over internet to any device (at least Android/iOS)?

What could be the methods that YI Home Cameras are using?

  • This would defeat the purpose of having IP addresses if you could do this. You cannot give the IP address of one thing to another. You can port forward, but that's different. – Brick Mar 15 at 17:06
  • We are not give router IP to raspberry pi we are forward a service port on router for raspberry pi internal port. thanks for answers please upvote us for our motivation.do not discourage us with downvote. – Kush Swarnkar Mar 18 at 6:15
  • To stream your pi to a device outside your network you need to port forward. You can use alternatives such as a VPN but depending on provider you could end up being charged. VPNs can cause bottle necks which could affect the quality of the stream. You could create your own VPN but you would need to open a port to use it. The YI cameras will use port forwarding. most routers now use UPNP to open ports for devices requesting it so the user doesnt have to. if you installed a YI camera the router would open the port as it probably has done for any existing devices that need it on your network. – rohtua Mar 22 at 11:32
1

This answer is mainly respected to the first revision of the question.

You already have public ip addresses for all your devices. So you can address all devices direct from the internet using its public ip addresses. You only have to setup the static public ip address on the RasPis. How to do it you can look at Setup a Static IP Address.

You have gotten the public ip addresses from your internet provider. He usually ensures that these addresses are visible in the internet. Most of them will give you a modem (or a router configured as modem) - not a router - to ensure that the ip addresses are part of the public subnet of the provider. Maybe you have to configure your own router this way. If your provider uses pppoe for internet connection there may be different settings. As you see there cannot be given general information here. It is primary a service of your internet provider.

And as you also see the only issue belonging to Raspberry Pi is to give them a static ip address. Everything else is part of the internet modem/router. So for details about the internet connection you should ask your internet provider and if further help is needed you can ask at https://serverfault.com

2

You need to port forward to the pi's from your router. If you look in the settings there should be options related to port forwarding. Once you've set up a forward you can access it using your external IP.

  • we are already setup port forwarding on router for raspberry pi. but we didn't satisfy this solution because it can open a socket for publicly use.can you help us tell best api for live video streaming for raspberry pi with picamera. thank you very much for your answer. – Kush Swarnkar Mar 15 at 12:23
  • I'm sorry there isn't another way. You can port forward to allow external access to the internal server or you can keep all ports closed and only use it on the local network. If you're worried about security have a look at tools such as fail2ban and htaccess files to control access. If you're wanting to access anything externally you need to allow access to the port. If all ports were closed on your router you wouldn't be able to access the internet. Ports such as 80 are open by default to allow for access like that. If you do a quick search there's lots of articles about securing servers. – rohtua Mar 15 at 12:55
  • okay, let us look up. – Kush Swarnkar Mar 15 at 13:14
1

If port forwarding and using your WAN IP address is distasteful for you then you could try setting up a VPN hosted on a more secure host instead. You'd need to then connect each mobile/remote device and the Pi to the VPN in order to view the stream.

For example, I've used ZeroTier for this sort of thing in the past to get SSH access to my Pi without having to configure anything on the WAN gateway or needing to know the WAN IP address either. They have clients for Linux, Mac/iOS, Windows, and Android and it's free for small networks (<101 nodes) and reasonable for larger ones.

Other VPN solutions are available and might be better suited if you want to tweak the system.

1

You could use Youtube Live Streaming or Other Live Streaming Software like Wowza, Where global IP and port forwarding setup is not required.

To start with checkout this link. https://www.raspberrypi.org/blog/youtube-live-streaming-docker/

For example I am using following ffmpeg command to Stream to my Youtube channel from raspberry pi

ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f v4l2 -c:v rawvideo -i /dev/video0 -c:v h264_omx  -r 60 -s 960x540 -b 6000k  -threads 6  -acodec aac -ab 128k -g 50 -strict experimental -f flv <Youtube rtmp link here>
1

If you want to stream, you can use MotionEye. It's easy to add to Raspberry Pi. You can use bash script from this GitHub project.

It will be available from your-raspberry-ip:8888. Also, you can see and implement base configuration from This link. It contains adding static ip-address, which is important to be sure, that you can get access every time for your raspberry.

If you have questions - create issue.

Best regards, Roman.

  • It is not a feasible solution. there is problem in this method it can only be used in local network. – Kush Swarnkar Mar 22 at 9:02
  • It can be used outside via adding static IP-address for your router and throw port to your local raspberry. – Roman Mstislavov Mar 22 at 9:31
  • we are not going for port forwarding on router. – Kush Swarnkar Mar 22 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.