Streaming from the input
Moderator: flatmax
Streaming from the input
Hi
I am at last getting some time to have a play.
I don't know where to begin with what I want to achieve, I think the theory is pretty simple and jack should be able to link any input to any output but I've never tried anything like this before. Do I go for a dedicated distro? Or work with Raspbian?
What I would like to do is:
Take the phono input, digitise it and stream it to a googlecast/another pi.
If this can happen with the audio being passed through that's good but as long as the streaming is happening I can use that for local input to my amp.
This setup will allow me to play vinyl or a CD in my living room and listen to it in my kitchen.
http://blog.tkjelectronics.dk/2013/06/h ... o-latency/ is the closest I've found but before I start does anyone have any more specific guidance?
I am at last getting some time to have a play.
I don't know where to begin with what I want to achieve, I think the theory is pretty simple and jack should be able to link any input to any output but I've never tried anything like this before. Do I go for a dedicated distro? Or work with Raspbian?
What I would like to do is:
Take the phono input, digitise it and stream it to a googlecast/another pi.
If this can happen with the audio being passed through that's good but as long as the streaming is happening I can use that for local input to my amp.
This setup will allow me to play vinyl or a CD in my living room and listen to it in my kitchen.
http://blog.tkjelectronics.dk/2013/06/h ... o-latency/ is the closest I've found but before I start does anyone have any more specific guidance?
Re: Streaming from the input
You can do this, more simply then you would expect !
Plug your sound source to the input of the audio injector stereo card. Setup the mixer to enable input from the lines rather then the microphone.
To do the streaming, perhaps the simplest approach is using rtp from ffmpeg (avconv).
Here is an example (to get you started) which would need some work :
ffmpeg -f alsa -i plughw -f rtp rtp://destinationHost:port
For example it would be better to drop the "-i plughw" and just use the default audio device (the audio injector) if that works.
Then to play you can do :
ffplay rtp://sourceHost:port
Matt
Plug your sound source to the input of the audio injector stereo card. Setup the mixer to enable input from the lines rather then the microphone.
To do the streaming, perhaps the simplest approach is using rtp from ffmpeg (avconv).
Here is an example (to get you started) which would need some work :
ffmpeg -f alsa -i plughw -f rtp rtp://destinationHost:port
For example it would be better to drop the "-i plughw" and just use the default audio device (the audio injector) if that works.
Then to play you can do :
ffplay rtp://sourceHost:port
Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
-
- Posts: 4
- Joined: Mon Feb 27, 2017 5:12 am
Re: Streaming from the input
I have a variation on this request which I'm struggling to implement.
My audio client is a Marantz midi system which can act as a DLNA/UPnP client. So I'd like to publish the audio stream (from the record deck) via DLNA.
I've been bashing my head against the wall of different incantations of pulseaudio and rygel to no avail. Am I barking up the wrong tree? (i.e. is there a simple, elegant solution to this similar to the one you've described above?)
TIA,
Gareth
My audio client is a Marantz midi system which can act as a DLNA/UPnP client. So I'd like to publish the audio stream (from the record deck) via DLNA.
I've been bashing my head against the wall of different incantations of pulseaudio and rygel to no avail. Am I barking up the wrong tree? (i.e. is there a simple, elegant solution to this similar to the one you've described above?)
TIA,
Gareth
Re: Streaming from the input
Hi there,
DLNA defines 3 systems :
1] control ... can be used to route audio from a server to a renderer.
2] A server which has music on it or a live stream
3] A renderer which is to play the music.
On your Pi, setup a suitable renderer, like Upnp or whatever. Then on your phone or computer or pi, use a DLNA controller app to select the music on the router you want to play on your Pi renderer !
Does this sound like it will work ?
Matt
DLNA defines 3 systems :
1] control ... can be used to route audio from a server to a renderer.
2] A server which has music on it or a live stream
3] A renderer which is to play the music.
On your Pi, setup a suitable renderer, like Upnp or whatever. Then on your phone or computer or pi, use a DLNA controller app to select the music on the router you want to play on your Pi renderer !
Does this sound like it will work ?
Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
-
- Posts: 4
- Joined: Mon Feb 27, 2017 5:12 am
Re: Streaming from the input
Thanks Matt,
Yes in theory but I've not explained it well enough. Not-very-good diagram attached, but I have the record player in the living room, attached via RCA cable to an RPi3 via an Audioinjector stereo card. In the kitchen I have the Marantz midi system which has embedded wifi and is DLNA compatible. So via your definition, the Marantz has (1) and (3) - a UI to select a DLNA server on the network and then media or the stream running on it (i.e. the control) - and then the means to output it to speakers (i.e. the renderer).
I want the RPi to be (2) - the server - to convert the analog audio input from the record player through the line inputs on the Audioinjector and then present that as a live audio stream via a DLNA server. Specifically (I think), the Pi just needs to be the server, not the renderer. But I can't figure out the magic I need between pulseaudio/rygel/minidlna/whatever to get from Audioinjector line in to DLNA live stream out.
Hopefully that's a bit clearer. My fallback is to use a second RPi in the client/server configuration you describe above (viewtopic.php?f=5&t=64#p176) and then pump audio out from that into the line inputs on the Marantz, but I'd much rather use the native DLNA controller/renderer on the Marantz if I can get the server end working.
I'm going to carry on throwing some google fu at the problem, but if anyone has figured out the magic incantations to get pulseaudio/rygel/minidlna/a.n.other working together in this way, I'd love to know about it.
Yes in theory but I've not explained it well enough. Not-very-good diagram attached, but I have the record player in the living room, attached via RCA cable to an RPi3 via an Audioinjector stereo card. In the kitchen I have the Marantz midi system which has embedded wifi and is DLNA compatible. So via your definition, the Marantz has (1) and (3) - a UI to select a DLNA server on the network and then media or the stream running on it (i.e. the control) - and then the means to output it to speakers (i.e. the renderer).
I want the RPi to be (2) - the server - to convert the analog audio input from the record player through the line inputs on the Audioinjector and then present that as a live audio stream via a DLNA server. Specifically (I think), the Pi just needs to be the server, not the renderer. But I can't figure out the magic I need between pulseaudio/rygel/minidlna/whatever to get from Audioinjector line in to DLNA live stream out.
Hopefully that's a bit clearer. My fallback is to use a second RPi in the client/server configuration you describe above (viewtopic.php?f=5&t=64#p176) and then pump audio out from that into the line inputs on the Marantz, but I'd much rather use the native DLNA controller/renderer on the Marantz if I can get the server end working.
I'm going to carry on throwing some google fu at the problem, but if anyone has figured out the magic incantations to get pulseaudio/rygel/minidlna/a.n.other working together in this way, I'd love to know about it.
- Attachments
-
- Screen Shot 2017-03-02 at 23.15.50.png (102.36 KiB) Viewed 43103 times
Re: Streaming from the input
OK, so we should talk about streaming from the Pi.
One way is most likely to setup a wav file stream out of the pi. This stream can then (hopefully) be sent to the DLNA renderer.
To stream I will use ffserver on ubuntu or debian we install it with sudo apt-get install ffmpeg - if we can't install that directly on the Pi, let me know and we can find a solution.
Here is an example setup which may need some debugging to get an audio stream from the Pi and served as a wav file. The ffserver.conf file listing is at the end of this post.
Using the ffserver.conf file we firstly run the ffserver :
If that runs, then we should be able to see it in the webbrowser at http://localhost:8090/stat.html
From memory it is setup to stream audio from the IP address 192.168.0.100. There is probably a way to make it do that for all IPs.
Now that your ffserver is setup, you will want to start streaming from the audio input. We will use ffmpeg (may be avconv on the pi) to do this. I forget which one of these two commands work, perhaps you can experiment and report back ?
To test the stream is working, you should probably execute ffplay (avconv) pointing it to http://192.168.0.100:8090/inputAudio.wav. Don't forget to change the IP address here to reflect the IP address you are using on the Pi. Also same goes for the ffserver.conf file.
Again, I did this a while ago, however it gives you enough information to get started and debug this setup. Please let us know how you progress and the final solution.
thanks
Matt
One way is most likely to setup a wav file stream out of the pi. This stream can then (hopefully) be sent to the DLNA renderer.
To stream I will use ffserver on ubuntu or debian we install it with sudo apt-get install ffmpeg - if we can't install that directly on the Pi, let me know and we can find a solution.
Here is an example setup which may need some debugging to get an audio stream from the Pi and served as a wav file. The ffserver.conf file listing is at the end of this post.
Using the ffserver.conf file we firstly run the ffserver :
Code: Select all
ffserver -f ffserver.conf
From memory it is setup to stream audio from the IP address 192.168.0.100. There is probably a way to make it do that for all IPs.
Now that your ffserver is setup, you will want to start streaming from the audio input. We will use ffmpeg (may be avconv on the pi) to do this. I forget which one of these two commands work, perhaps you can experiment and report back ?
Code: Select all
ffmpeg -f alsa -ac 2 -ar 48000 -i hw:0,0 -acodec pcm_s32le -f ffm -acodec wav http://192.168.0.100:8090/inputAudio.wav
Code: Select all
ffmpeg -f alsa -ac 2 -ar 48000 -i hw:0,0 -acodec pcm_s16le -f ffm http://127.0.0.1:8090/inputAudio.ffm
Again, I did this a while ago, however it gives you enough information to get started and debug this setup. Please let us know how you progress and the final solution.
thanks
Matt
Code: Select all
# save this file as ffserver.conf
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 15000
# Access log file (uses standard Apache log file format)
# '-' is the standard output.
CustomLog -
##################################################################
<Feed inputAudio.ffm>
File /tmp/inputAudio.ffm
FileMaxSize 200K
#Launch ffmpeg
# Only allow connections from localhost to the feed.
ACL allow 127.0.0.1 192.168.0.100
</Feed>
##################################################################
<Stream inputAudio.wav>
# coming from live feed 'feed1'
Feed inputAudio.ffm
Format wav
AudioChannels 2
AudioSampleRate 48000
AudioBitRate 3072
NoVideo
AVOptionAudio flags +global_header
#Preroll 1
</Stream>
##################################################################
# Special streams
# Server status
<Stream stat.html>
Format status
# Only allow local people to get the status
ACL allow localhost
</Stream>
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
-
- Posts: 4
- Joined: Mon Feb 27, 2017 5:12 am
Re: Streaming from the input
Thanks Matt. I'm giving this a go this evening - but having to compile ffmpeg on my RPi3 which I understand will take a few hours. I'll report back!
Re: Streaming from the input
Check if you have avconv. It is the same application - same code base.
Install like so :
sudo apt-get install libav-tools
Matt
Install like so :
sudo apt-get install libav-tools
Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
-
- Posts: 4
- Joined: Mon Feb 27, 2017 5:12 am
Re: Streaming from the input
OK, here's where I've got to.
The ffmpeg/ffserver approach you describe above is working but audio's breaking up. However, I've got the following working well:
SERVER - Raspberry PI plugged into record deck (hostname record-player)
ffmpeg -f alsa -ac 2 -ar 48000 -i hw:0,0 -acodec mp2 -f rtp rtp://kitchen-audio-bridge:1234
CLIENT - Raspberry Pi plugged into midi system (hostname kitchen-audio-bridge)
avplay -i rtp://127.0.0.1:1234/ (needs to be run as root for some reason)
This is working well, currently. Bitrate of 389.4kbits.
I could wrap all of this up in some scripts and be done, so thanks for the help in getting this far. However, is there any way of now tying this to DLNA so I can eliminate the second Raspberry Pi?
The ffmpeg/ffserver approach you describe above is working but audio's breaking up. However, I've got the following working well:
SERVER - Raspberry PI plugged into record deck (hostname record-player)
ffmpeg -f alsa -ac 2 -ar 48000 -i hw:0,0 -acodec mp2 -f rtp rtp://kitchen-audio-bridge:1234
CLIENT - Raspberry Pi plugged into midi system (hostname kitchen-audio-bridge)
avplay -i rtp://127.0.0.1:1234/ (needs to be run as root for some reason)
This is working well, currently. Bitrate of 389.4kbits.
I could wrap all of this up in some scripts and be done, so thanks for the help in getting this far. However, is there any way of now tying this to DLNA so I can eliminate the second Raspberry Pi?
Re: Streaming from the input
Good work !
OK - to get rid of the second Pi, that would be nice.
I am not sure if your DLNA player can use the rtp as it is. That is why I think you may have to get your ffserver setup working nicely.
You could do some tests, for example, with ffserver stream you have working (with dropouts), see if the DLNA player can play it, use your computer or phone to try to route the audio stream from the Pi to the DLNA player. Once you work out what protocol to provide at the ffserver side for the DLNA player (your Marantz) to be able to play, then you can work on improving the streaming experience.
To improve streaming, can you do some tests by reducing the bit rate of the audio you send over the network ? For example, can you reduce the sample rate to 44.1 kHz and bits to 16 bits, or instead of using an uncompressed stream, perhaps you can try to use an mp3 stream ?
RTP is a UDP protocol, which means it has VERY low overheads. I think DLNA is based on a TCP protocol which means high overheads for network traffic, that is why I think dropping the bitrate may work nicely.
thanks
Matt
OK - to get rid of the second Pi, that would be nice.
I am not sure if your DLNA player can use the rtp as it is. That is why I think you may have to get your ffserver setup working nicely.
You could do some tests, for example, with ffserver stream you have working (with dropouts), see if the DLNA player can play it, use your computer or phone to try to route the audio stream from the Pi to the DLNA player. Once you work out what protocol to provide at the ffserver side for the DLNA player (your Marantz) to be able to play, then you can work on improving the streaming experience.
To improve streaming, can you do some tests by reducing the bit rate of the audio you send over the network ? For example, can you reduce the sample rate to 44.1 kHz and bits to 16 bits, or instead of using an uncompressed stream, perhaps you can try to use an mp3 stream ?
RTP is a UDP protocol, which means it has VERY low overheads. I think DLNA is based on a TCP protocol which means high overheads for network traffic, that is why I think dropping the bitrate may work nicely.
thanks
Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector
Who is online
Users browsing this forum: No registered users and 5 guests