savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.41k stars 130 forks source link

System audio output as liquidsoap input #618

Closed anitta-paul closed 6 years ago

anitta-paul commented 6 years ago

Hi, is there any way to accept the system audio output as the input to liquidsoap?? I tried many liquidsoap plugins but not working as intended. Trying to implement it in nodejs.

savonet-users commented 6 years ago

Which operating system? You would think this should be easy. I managed to do it in Linux, but it was very difficult and required a fair amount to trial and error. And it even depends on which Linux sound system you are using (ALSA or PulseAudio).

I seem to remember that there is a Windows program available ("patch"? "virtual cable"?). I have never tried it, and there is a small purchase price, but it sounded fairly simple to use.

Nick

On Wed, Aug 29, 2018 at 12:55 PM anitta-paul notifications@github.com wrote:

Hi, is there any way to accept the system audio output as the input to liquidsoap?? I tried many liquidsoap plugins but not working as intended. Trying to implement it in nodejs.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/618, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23yy477QkAsdTNPgaHMV_pK9uIOdAOks5uVseCgaJpZM4WR8sV .


Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users

anitta-paul commented 6 years ago

I am trying to implement it in LINUX OS. I used ALSA sound sound system. But it took the input from the recording device connected to the system and broadcasted it. What I want is to broadcast the audio that is being played in the system.

input.alsa()

savonet-users commented 6 years ago

To do this, you need to create an ALSA loopback device. I spent a lot of time researching this, and am still not sure I understand. Part of the problem is that there is more than one way to do it. What are you using to output the audio to ALSA? If you can select the output device, then it is a little easier. I wanted to capture the output from Chrome, so it was more difficult.

Here is the .asoundrc that I used to capture the output from Chrome and direct it to a file. You should be able to do something like this, and pipe it over to Liquidsoap.

pcm.teemp3 { type file format "raw" slave.pcm "hw:0,0" file '|/usr/bin/lame -S -r -s 44100 --bitwidth %b -m m - /home/madlibs/madl$ } pcm.teeraw { type empty slave.pcm "tee:null,'/home/madlibs/rawout.raw',raw"

48000 S16_LE 2ch (aplay -t raw -f dat)

} pcm.teewav { type empty slave.pcm "tee:null,'/home/madlibs/wavout.wav',wav" } pcm.!default { type empty slave.pcm "teemp3" }

Here is where I found my example: https://manual.audacityteam.org/man/tutorial_recording_computer_playback_on_linux.html

Please post your progress if you can. It would be nice to include it in the documentation when we figure this out.

Nick

On Thu, Aug 30, 2018 at 12:41 AM anitta-paul notifications@github.com wrote:

I am trying to implement it in LINUX OS. I used ALSA sound sound system. But it took the input from the recording device connected to the system and broadcasted it. What I want is to broadcast the audio that is being played in the system.

input.alsa()

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/618#issuecomment-417187801, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23y_UoX0odfLLwJW9u5F5JE3hraEZYks5uV2zbgaJpZM4WR8sV .


Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users

anitta-paul commented 6 years ago

Thanks Nick, I made it work using the ALSA loopback device.

anitta-paul commented 6 years ago

Hey Nick, I have posted a new issue. Please see If you could help.

https://github.com/savonet/liquidsoap/issues/619

savonet-users commented 6 years ago

Hi Anitta

I have not done the details. But this should be pretty easy. Instead of trying to point the live broadcast to icecast, you just tell liquidsoap to pick up the live broadcast when that is available, and use the ALSA input when the live is not available.

The "Quick Start" guide has the basics. See the section "Input from another streaming server", and then at the end the "A simple radio" see about switching between sources.

Nick

On Fri, Aug 31, 2018 at 3:12 AM anitta-paul notifications@github.com wrote:

Hey Nick, I have posted a new issue. Please see If you could help.

619 https://github.com/savonet/liquidsoap/issues/619

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/618#issuecomment-417574167, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23y5g7pthdQ5IwK_1qO_GkejwoOXmxks5uWOGygaJpZM4WR8sV .


Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users

savonet-users commented 6 years ago

Hi anitta… can you please include the .asoundrc file that you used in a reply to this? Along with any notes or problems you ran into?

That might help the next person. Maybe we can even add a little bit to the documentation.

Nick

On Fri, Aug 31, 2018 at 2:46 AM anitta-paul notifications@github.com wrote:

Thanks Nick, I made it work using the ALSA loopback device.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/618#issuecomment-417568508, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23y5LbWa5F4HZCgKk0zBMjF0Cpr-fXks5uWNuTgaJpZM4WR8sV .


Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users

anitta-paul commented 6 years ago

I didn't use a .asoundsrc file. I instead used the volume control to switch between the sound devices. It worked fine.

Another problem that I'm facing now is that, I tried to use an Amazon EC2 instance to implement the system but they don't have a sound device(ALSA) it seems. Is there any cloud service that comes with a sound card? Or is there any possibility to implement the system in a cloud server without sound card??

PEC-Sanction commented 5 years ago

Hi ! I want to do the same using ALSA and liquidsoap (on a Raspberry pi). Unfortunately, the solution provided by Nick is not working. I just want to be sure, which input source I should use in my liquidsoap script ? Thanks in advance ! ;)

savonet-users commented 5 years ago

If you share your ALSA configuration, I will try to take a look at it.

ALSA can be very confusing.

Nick

On Wed, Nov 21, 2018 at 9:21 AM PEC-Sanction notifications@github.com wrote:

Hi ! I want to do the same using ALSA and liquidsoap (on a Raspberry pi). Unfortunately, the solution provided by Nick is not working. I just want to be sure, which input source I should use in my liquidsoap script ? Thanks in advance ! ;)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/savonet/liquidsoap/issues/618#issuecomment-440677701, or mute the thread https://github.com/notifications/unsubscribe-auth/Am23y_rYHEVdoxxnC01xtclsosdzrveUks5uxWE8gaJpZM4WR8sV .


Savonet-users mailing list Savonet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/savonet-users

PEC-Sanction commented 5 years ago

Thank you for the quick answer !

Just for information, I installed liquidsoap using opam (normally I have liquidsoap v1.3.4).

My .liq script:

#!/usr/bin/liquidsoap
set("log.file.path", "/tmp/radio.log")
stream = input.alsa(device="???")
output.icecast(%vorbis,
 host="localhost",
 port=8000,
 password="password",
 mount="radio.ogg",
 stream)

My ~/.asoundrc file:

pcm.teemp3 {
 type file
 format "raw"
 slave.pcm "hw:0,0"
 file '|/usr/bin/lame -S -r -s 44100 --bitwidth %b -m m - /tmp/out.mp3
}

pcm.teeraw {
 type empty
 slave.pcm "tee:null,'/tmp/out.raw',raw"
 # 48000 S16_LE 2ch (aplay -t raw -f dat)
}

pcm.teewav {
 type empty
 slave.pcm "tee:null,'/tmp/out.wav',wav"
}

pcm.!default {
 type empty
 slave.pcm "teemp3"
}

aplay -l command:

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Thanks in advance ! Loïc

PEC-Sanction commented 5 years ago

Hi Nick !

Did you have the time to take a look at my ALSA configuration ?

Thank you ! Loïc