jahau
Posts: 12
Joined: Thu Dec 20, 2018 11:32 am

UV4L with audio only and multiple clients

Sat Jan 05, 2019 6:59 pm

I've installed the uv4l pretty much following the guide: https://www.linux-projects.org/uv4l/installation/

...and already checked links like viewtopic.php?t=108702

How do I stream something that I play on the raspberry (e.g. mp3), just the audio and just to test whether this works at all? I don't have camera attached or any other peripherals. I've tried this using the default page that comes with the uv4l: WebRTC two-way Audio/Video/Data Intercom & Recorder (in this case http://192.168.1.2:9080/stream/webrtc).

I've checked chrome://webrtc-internals/ on the client machine and there's at least something related to audio existing but I cannot hear any sound on the client machine. How do I enable multiple clients to uv4l? Is separate port need to be defined or some channel or whatever?

Thanks.

beefalo
Posts: 4
Joined: Thu Jan 03, 2019 10:43 pm

Re: UV4L with audio only and multiple clients

Sun Jan 06, 2019 5:51 am

This is what I use to steam just audio over webrtc.

Code: Select all

sudo uv4l --driver dummy --enable-server  --server-option=--enable-webrtc-audio=yes --server-option=--enable-webrtc-video=no
I don't know of any way to directly use an mp3 as the audio source but you could probably set something up with alsa so that it pipes the mp3 into a fake audio input that you can set as the default. That should get uv4l to pick it up as the audio input.

Then you should be able to call on the rtc page and play the audio.

jahau
Posts: 12
Joined: Thu Dec 20, 2018 11:32 am

Re: UV4L with audio only and multiple clients

Sun Jan 06, 2019 7:18 am

I've checked and the uv4l is using conf-file in this environment ("/etc/uv4l/uv4l-uvc.conf").

For some reason there are two processes running (/usr/bin/uv4l -f -k --sched-fifo --mem-lock --config).

Where is it told to uv4l to use certain source for the audio?

How do I define several "channels" for the uv4l so that several users could attach to the stream? Does anybody have experience about the latency when there are several users attached to the same stream?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: UV4L with audio only and multiple clients

Mon Jan 07, 2019 3:34 am

jahau wrote:
Sat Jan 05, 2019 6:59 pm
How do I stream something that I play on the raspberry (e.g. mp3), just the audio and just to test whether this works at all?
Check this tutorial, it should do what you need:

https://www.linux-projects.org/uv4l/tut ... d-sharing/

beefalo
Posts: 4
Joined: Thu Jan 03, 2019 10:43 pm

Re: UV4L with audio only and multiple clients

Mon Jan 14, 2019 10:26 pm

Were you able to get this to work? I set up the webrtc audio sharing but could only connect one client at a time.

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: UV4L with audio only and multiple clients

Mon Jan 14, 2019 10:43 pm

beefalo wrote:
Mon Jan 14, 2019 10:26 pm
Were you able to get this to work? I set up the webrtc audio sharing but could only connect one client at a time.
You need Janus as a gateway (it can be installed on the same Rpi). There is a paragraph somewhere in the linked page mentioned before showing how to broadcast to a Janus videoroom and there are other examples more specific about UV4L+Janus.

beefalo
Posts: 4
Joined: Thu Jan 03, 2019 10:43 pm

Re: UV4L with audio only and multiple clients

Thu Jan 17, 2019 6:43 pm

RpiName wrote:
Mon Jan 14, 2019 10:43 pm
beefalo wrote:
Mon Jan 14, 2019 10:26 pm
Were you able to get this to work? I set up the webrtc audio sharing but could only connect one client at a time.
You need Janus as a gateway (it can be installed on the same Rpi). There is a paragraph somewhere in the linked page mentioned before showing how to broadcast to a Janus videoroom and there are other examples more specific about UV4L+Janus.
What are you using as the clients to receive the pi audio?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: UV4L with audio only and multiple clients

Thu Jan 17, 2019 9:23 pm

beefalo wrote:
Thu Jan 17, 2019 6:43 pm
What are you using as the clients to receive the pi audio?
uv4l itself or the browser

jahau
Posts: 12
Joined: Thu Dec 20, 2018 11:32 am

Re: UV4L with audio only and multiple clients

Sun Jan 20, 2019 2:07 pm

Actually, I'm having trouble testing the audio in UV4L, I used "WebRTC two-way Audio/Video/Data Intercom & Recorder" demo page for this.

How do I cast the audio from Raspberry PI to e.g. PC (Chrome)? Do I need to check the option "Audio: microphone/other input". If I do that and click Call, I get "An error has occurred. Check media device, permissions on media and origin".

I did as the tutorial suggested, https://www.linux-projects.org/home/wp- ... sound.conf. I can hear the audio on the Raspberry (I have speakers for testing purposes attached to it) but cannot hear any audio from the Chrome (Raspberry/WebRTC is accessible in the address http://192.168.1.4:9080/stream/webrtc).

Additionally it's said here https://www.linux-projects.org/uv4l/installation/ to install uv4l-uvc. Is this really needed? It seems to create separate configuration file /etc/uv4l/uv4l-uvc.conf and includes same parameters as /etc/uv4l/uv4l-raspidisp.conf. This is very confusing.

Any ideas?

jahau
Posts: 12
Joined: Thu Dec 20, 2018 11:32 am

Re: UV4L with audio only and multiple clients

Thu Jan 31, 2019 5:41 pm

Anyone any ideas to proceed on this? Thanks.

Di0Z
Posts: 1
Joined: Fri Mar 15, 2019 9:51 am

Re: UV4L with audio only and multiple clients

Fri Mar 15, 2019 9:56 am

My answer may comes a little late, but if you have pulseaudio as audio server, you have to disable the service for audio to work with UV4L :

Code: Select all

sudo service pulseaudio stop
.
And maybe you will have to restart UV4L services :

Code: Select all

sudo service uv4l_raspidisp restart
sudo service raspidisp_server restart

janeksz
Posts: 5
Joined: Fri May 22, 2015 10:34 am

Re: UV4L with audio only and multiple clients

Fri Sep 27, 2019 6:12 am

Hi,
Was anyone able to solve this problem?
I would like to stream audio from I2s microphone on headless raspberry pi using webrtc and uv4l.
Does it work? I am unable to make it work so far.
Jan

whenagain
Posts: 5
Joined: Sat Oct 19, 2019 8:45 pm

Re: UV4L with audio only and multiple clients

Mon Oct 28, 2019 12:18 am

I'd love to know if anyone's gotten this working as well?
I have a RPi0w accessible over my LAN hosting UV4L via HTTPS and an audio input via USB sound card. I can access the WebRTC interface but I can't hear anything. The sound is coming out fine on the Pi itself via a test speaker.

whenagain
Posts: 5
Joined: Sat Oct 19, 2019 8:45 pm

Re: UV4L with audio only and multiple clients

Tue Oct 29, 2019 4:40 pm

I just got this working!

Here's what I did:

The short version of my project is I just want to stream audio from any device plugged into the "mic" input on my USB Audio Adapter (really using it as a line-in). I will be the only user.

At this point, I am assuming that you have UV4L installed, and you can access the HTTPS front-end from another PC. When you go to the Web RTC page and click the "Call" button, nothing happens.

I think the main issue was the webrtc-recdevice-index server option in my uv4l-raspicam.conf file.
I ran this to figure out the right value:

Code: Select all

[email protected]:~ $ arecord -L | grep CARD
sysdefault:CARD=Device
front:CARD=Device,DEV=0
surround21:CARD=Device,DEV=0
surround40:CARD=Device,DEV=0
surround41:CARD=Device,DEV=0
surround50:CARD=Device,DEV=0
surround51:CARD=Device,DEV=0
surround71:CARD=Device,DEV=0
iec958:CARD=Device,DEV=0
dmix:CARD=Device,DEV=0
dsnoop:CARD=Device,DEV=0
hw:CARD=Device,DEV=0
plughw:CARD=Device,DEV=0
Counting the output results from zero, the value i needed was plughw:CARD=Device,DEV=0, or 12 for my USB Audio Adapter.

Here is the trimmed down version of my uv4l-raspicam.conf file with only the options enabled. Make sure your passwords, key/crt file locations, etc are correct.

Code: Select all

##################################
# uv4l core options
##################################

driver = dummy
enable-server = auto

#################################
# streaming server options
#################################

 server-option = --port=8080
 server-option = --bind-host-address=0.0.0.0
 server-option = --md5-passwords=no
 server-option = --user-password=password
 server-option = --admin-password=password

### HTTPS options:
 server-option = --use-ssl=yes
 server-option = --ssl-private-key-file=/etc/ssl/private/selfsign.key
 server-option = --ssl-certificate-file=/etc/ssl/private/selfsign.crt

### WebRTC options:
 server-option = --enable-webrtc=yes
 server-option = --enable-webrtc-datachannels=no
 server-option = --enable-webrtc-video=no
 server-option = --enable-webrtc-audio=yes
 server-option = --webrtc-receive-video=no
 server-option = --webrtc-receive-datachannels=no
 server-option = --webrtc-receive-audio=no
 server-option = --webrtc-audio-layer=1
 server-option = --webrtc-recdevice-index=12
 server-option = --webrtc-vad=no
 server-option = --webrtc-echo-cancellation=no
 server-option = --webrtc-enable-hw-codec=yes
 server-option = --webrtc-max-playout-delay=0
 server-option = --webrtc-cpu-overuse-detection=no

### Other options:
 server-option = --enable-builtin-ui=yes
 server-option = --enable-control-panel=yes
 server-option = --enable-rest-api=yes
Once set, I restarted my UV4L service, went to the Web RTC page, clicked "Call" and my audio started coming in! It was a bit hot/saturated, so I just cut the Microphone Capture value in the USB Audio Device Settings to about 50%.

I hope this helps the few others working on this, or who have the same problem in the future.

whenagain
Posts: 5
Joined: Sat Oct 19, 2019 8:45 pm

Re: UV4L with audio only and multiple clients

Tue Oct 29, 2019 4:42 pm

janeksz wrote:
Fri Sep 27, 2019 6:12 am
Hi,
Was anyone able to solve this problem?
I would like to stream audio from I2s microphone on headless raspberry pi using webrtc and uv4l.
Does it work? I am unable to make it work so far.
Jan
Hi Jan,

I just posted how I got this working in the post above. Might this help you if you're still working on your project?

Return to “Other projects”