2

I am looking for a way to live stream the audio from my USB microphone through a WiFi hotspot via mobile data to an online website / the cloud. My goal is to stream my performances to the people who could not come. Since there is no available WiFi usually, I wish to use my phone as a WiFi hotspot, connect the Pi and have it livestreaming.

Icecast could be used by port forwarding, but that is not possible on a phone hotspot.

I found multiple ways for livestreaming video to YouTube, and if it is possible to add my audio to such livestream I would be happy to add a Pi Camera. But I couldn't find if it is possible to add audio to a YouTube livestream.

Does anyone have a recommendation on how to solve this problem?

  • 1
    Hello and welcome -- Add more information about this line: "Alternatively, I could also hook up a Pi camera and make some sort of YouTube livestream, but I couldn't find any information on adding audio to such livestream." – M. Rostami Mar 22 at 13:15
  • 1
    Thanks! I edited the line about the camera – StevenCellist Mar 22 at 13:45
3

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

  1. Sign up on cloudflare and add your domain name there.
  2. Add the Cloudflare preferred NS1/NS2 DNS to your domain name on the domain name registrar.
  3. Add these DNS query on your domain dashboard on Cloudflare:
    Cloudflare DNS query
    • 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
  1. installation:
    Video Streaming from raspberry to an external server

  2. Configuration:
    /etc/motion/motion.conf
    You can configure stream quality according your bandwidth limitations.

  3. 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

| improve this answer | |
  • 1
    Wow, thanks for this very elaborate answer! I will dive in tomorrow on everything you mentioned here. A question in advance: is it possible to make my mobile network public IP address static? I don't really want to re-configure my whole setup every time I want to launch the livestream. Also, do you know if there's a way to merge the audio and video? It might get me syncing problems, but opening two websites is also not ideal. I'm sure your suggestions will work and it helps me a lot!! But I want to make it easy for everyone involved :) – StevenCellist Mar 22 at 13:52
  • 1
    is it possible to make my mobile network public IP address static? -- I don't think so. However, it's related to your service provider. Contact with them. || do you know if there's a way to merge the audio and video? -- No, you don't need to open up two different websites. It's all about one server (RPi) and an address. You should create an HTML page to open these two different ports on a single page. Although, I'll search and improve the answer in this case. – M. Rostami Mar 22 at 14:02
  • 1
    I don't really want to re-configure my whole setup every time I want to launch the livestream. -- I added the Cloudflare API source, you can create an API client on the RPi by Python or whatever preferred language. It means, the RPi sends the new query (according to the new/changed IP address) to Cloudflare API to update that query. Others may help us in this case. – M. Rostami Mar 22 at 14:02
  • 1
    you can create an API client on the RPi -- ohh sounds great! that should solve the problem, then. create an HTML page to open these two different ports on a single page -- that seems to be a better solution than killing the gpu while trying to sync the video and audio. I'm planning on running this on a RPi Zero so I'd rather keep it as "light" as possible. Thanks!! – StevenCellist Mar 22 at 14:09
  • 1
    killing the GPU while trying to sync the video and audio -- Nice mention. -- Alright. Cheers, – M. Rostami Mar 22 at 14:12

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.