It's a complicated project. You should take it to some parts. It's my suggestion and would be happy if other experts improve it.
Domain name
Anyone can buy a domain name. To do so, you visit a domain name registrar, such as GoDaddy or Namecheap, key in the domain you want to buy, and pay a fee. You can't buy just any domain, of course only one that isn't already registered by another person or business and that bears a valid domain suffix.
Imagine you bought the domain name below:
domain.com
Find the public IP address
Find your mobile network public IP address by this site:
What's My IP Address? Networking Tools & More
Another approach is that you will connect raspberry pi to your mobile hotspot and fire this command:
curl icanhazip.com
Imagine you got the output below after running that command as your public IP address:
12.34.56.78
Cloudflare
- Sign up on cloudflare and add your domain name there.
- Add the Cloudflare preferred NS1/NS2 DNS to your domain name on the domain name registrar.
- Add these DNS query on your domain dashboard on Cloudflare:
12.34.56.78
would be your mobile network public IP address.
domain.com
would be the domain name that you have bought.
Set name servers on RPi
Add the line below to /etc/dhcpcd.conf
:
static domain_name_servers=1.1.1.1 8.8.8.8
The 1.1.1.1
is the Cloudflare nameserver.
Now, it's possible to access your raspberry pi over the internet by a domain name. Note that, generally the IP address of the mobile networks continuously changing and you should change it on Cloudflare manually or do it by the API.
Camera stream
Install motion
package on the raspberry pi as your camera web-streamer.
apt install motion
installation:
Video Streaming from raspberry to an external server
Configuration:
/etc/motion/motion.conf
You can configure stream quality according your bandwidth limitations.
Make it more secure:
Motion security
If you are concerned about the security of the streams, you can make it much more secure with some configuration and insight.
The motion
camera streams would be checked on domain.com:8081
.
Audio stream
The same as camera streaming, there is a lot of tools for you to stream your raspberry pi's audio.
For that, check the link below:
Streaming Audio from a remote Raspberry Pi to my computer
Don't stream audio on the same port number as motion
which is 8081
. You should choose another port number and match these two UDP streaming port by your web development coding like JS, etc.
Conclusion
You are going to set a domain name to your variable IP address then access your live Audio & Video/camera streaming. Note that it's a suggestion and you can find a better solution for each part.
References