Code Monkey home page Code Monkey logo

blast's Introduction

BLAST

Blast logo

Cast your Linux audio to DLNA receivers

You need pactl, parec and ffmpeg executables/dependencies on your system to run Blast.

If you have all that then you can launch blast and it looks like this when you run it:

[user@user blast]$ ./blast 
----------
DLNA receivers
0: Kitchen
1: Phone
2: Bedroom
3: Livingroom TV
----------
Select the DLNA device:
[1]
----------
Audio sources
0: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
1: alsa_input.pci-0000_00_1b.0.analog-stereo
2: bluez_output.D8_AA_59_95_96_B7.1.monitor
3: blast.monitor
----------
Select the audio source:
[2]
----------
Your LAN ip addresses
0: 192.168.1.14
1: 192.168.122.1
2: 2a04:ec00:b9ab:555:3c50:e6e8:8ea:211f
3: 2a04:ec00:b9ab:555:806d:800b:1138:8b1b
4: fe80::f4c2:c827:a865:35e5
----------
Select the lan IP address for the stream:
[0]
----------
2023/07/08 23:53:07 starting the stream on port 9000 (configure your firewall if necessary)
2023/07/10 23:53:07 stream URI: http://192.168.1.14:9000/stream.mp3
2023/07/08 23:53:07 setting av1transport URI and playing

There are also -debug and -headers flags if you want to inspect your DLNA device. Also, -log to inspect what parec and ffmpeg are doing.

Non-interactive usage and extra flags

[ugjka@ugjka blast]$ blast -h
Usage of blast:
  -bitrate int
        audio format bitrate (default 320)
  -bits int
        audio bitdepth (default 16)
  -channels int
        audio channels (default 2)
  -chunk int
        chunk size in seconds (default 1)
  -debug
        print debug info
  -device string
        dlna device's friendly name
  -dummy
        only serve content
  -format string
        stream audio format (default "mp3")
  -headers
        print request headers
  -ip string
        host ip address
  -log
        log parec and ffmpeg stderr
  -mime string
        stream mime type (default "audio/mpeg")
  -nochunked
        disable chunked tranfer endcoding
  -port int
        stream port (default 9000)
  -rate int
        audio sample rate (default 44100)
  -source string
        audio source (pactl list sources short | cut -f2)
  -useaac
        use aac audio
  -useflac
        use flac audio
  -uselpcm
        use lpcm audio
  -uselpcmle
        use lpcm little-endian audio
  -usewav
        use wav audio
  -version
        show blast version

Tips and tricks

  • If you choose blast.monitor as a source, you can send apps' audio to it (in pavucotrol or whatever applet you use) without streaming entire the desktop audio

blast.monitor example

  • If none of the built-in codecs presets satisfy you, you can specify your own with -mime and -format. For example: -mime audio/ac3 -format ac3, -mime audio/opus -format opus, -mime "audio/x-caf" -format caf or -mime "audio/mpeg" -format mp2

  • You can change audio features with -rate, -bits and -channels, e.g. blast -rate 48000 -bits 24 -channels 1

Building

You need the go and go-tools toolchain, also git

then execute:

git clone https://github.com/ugjka/blast
cd blast
go build

now you can run blast with:

[user@user blast]$ ./blast

Bins

Prebuilt Linux binaries are available on the releases page

Why not use pulseaudio-dlna?

This is for pipewire-pulse users.

Caveats

  • You need to allow port 9000 from LAN for the DLNA receiver to be able to access the HTTP stream, you can change it with -port flag
  • blast monitor sink may not be visible in the pulse control applet unless you enable virtual streams

Trivia

What on earth is "x-rincon-mp3radio"

License

MIT+NoAI License

Copyright (c) 2023 ugjka <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights/
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

This code may not be used to train artificial intelligence computer models
or retrieved by artificial intelligence software or hardware.

blast's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

belugame

blast's Issues

HTTP request crash

After I select the LAN ip address I'm getting this error:

2024/01/06 08:54:47 starting the stream on port 9000 (configure your firewall if necessary)
2024/01/06 08:54:47 stream URI: http://192.168.1.18:9000/stream
2024/01/06 08:54:47 setting av1transport URI and playing
goupnp: error performing SOAP HTTP request: Post "http://192.168.1.7:49152/upnp/control/rendertransport1": EOF

Streaming to Sony NAS-SV20i fails

The Sony receiver takes about 10 seconds to start a stream. blast errors out almost instantaneously (the display on the Sony shows that it tries to start loading it)

(1)(deck@steamdeck Downloads)$ ./blast -headers
----------
DLNA receivers
0: NAS-SV20i
----------
Select the DLNA device:
[0]
----------
Audio sources
0: filter-chain-source
1: filter-chain-sink.monitor
2: input.virtual-sink.monitor
3: output.virtual-source
4: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor
5: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__sink.monitor
6: alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source
7: alsa_output.pci-0000_04_00.1.hdmi-stereo-extra2.monitor
8: blast.monitor
----------
Select the audio source:
[7]
----------
Your LAN ip addresses
0: 192.168.100.87
1: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/07 15:49:49 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/07 15:49:49 stream URI: http://192.168.100.87:9000/stream.mp3
2024/02/07 15:49:49 setting av1transport URI and playing
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
transport: play: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Action Play failed
</errorDescription></UPnPError>

Feature: Allow streaming specific programs / audio to dlna

I was using pulseaudio-dlna with pavucontrol for some years and was very happy that with blast something actively developed was working out of the box for me too. ๐Ÿ‘

What I am missing in blast is that I can only direct all audio to my stereo and not select per application or output. For instance with pulseaudio-dlna/pavucontrol I m able to say e.g. music playing via vlc or ncmpcpp should go to my stereo but audio from firefox still via my computer's own speakers.

Would be great if you consider that as a future feature :)

bit-perfect streaming

Hi @ugjka

Thanks for the blast! First WORKING solution to stream audio from PipeWire to a remote DLNA renderer! Awesome!!!

I have the following enhancement request:

I have configured blast to stream losslessly by option -usewav and proper -rate and -bits values. That means that blast is sending the stream without any compression, but always resampling everything to upfront fixed samplerate/depth, unless you play the stream of the same samplerate/depth...

I am wondering if it would be possible to create a new option/options for blast, so then blast is simply only re-sending the stream of the same bitsdepth and samplerate as it receives at the moment, without any resampling.
For instance a new option -bitperfect, or extending existing options to accept "auto" values, like -rate auto and -bits auto.

I would appreciate your feedback.

Stream to Sonos - Errorcode 714

`
blast git:(main) ./blast

DLNA receivers
0: 192.168.158.24 - SYMFONISK Bookshelf

Select the DLNA device:
[0]

Audio sources
0: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink.monitor
1: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink.monitor
2: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink.monitor
3: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink.monitor
4: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__source
5: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__source
6: combined.monitor
7: bluez_sink.2C_FD_B4_86_0C_10.a2dp_sink.monitor
8: blast.monitor

Select the audio source:
[7]

Your LAN ip addresses
0: 192.168.158.48

Select the lan IP address for the stream:
[0]

2023/11/10 07:20:12 starting the stream on port 9000 (configure your firewall if necessary)
2023/11/10 07:20:12 stream URI: http://192.168.158.48:9000/stream
2023/11/10 07:20:12 setting av1transport URI and playing
SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: 714

blast git:(main) sudo ufw status
Status: Inactive
`

is this a bug ?
Error on play_media with UPnP Error 714 received: Illegal MIME-Type

if this is correct I found here you may add .mp3/mime-type:

home-assistant/core#37444

Detect endianess of the dlna device when sending raw lpcm

otherwise there's a high chance of garbled audio with incorrect endianess. See issue #7

Apparently BubbleUPNP on android does this somehow.

For now you have to set -bige flag if your device is big endian

This only seems to matter for lpcm streaming since stuff like wav and flac are little endian by definition

Blast unable to connect to DLNA Player

Hello,
I am trying to use blast with me moodeaudio device. This has always worked with pulseaudio-dlna, but as I am testing pipewire, i stumbled on your solution.

My Problem is this: I seem to be unable to connect to the device.
I Found ticket: Stream to Sonos - Errorcode 714
and the issue seems similar. I downloaded the "dlna-send.zip" and tested with it.
This is the result:

$ ./dlna-send https://ugjka.net/ircradio

DLNA receivers
0: Moode UPNP

Select the DLNA device:
[0]
SOAP fault. Code: s:Client | Explanation: UPnPError | Detail:

501
Action Failed

Could you please tell me how I could make this work?
thanks.

Hendrik-Jan Heins

Cannot stream audio to Xbox Series S - UPnPError

Run ./blast:

----------
DLNA receivers
0: XBOX
----------
Select the DLNA device:
[0]
----------
Audio sources
0: alsa_output.usb-Generic_USB_Audio-00.HiFi_7_1__hw_Audio_3__sink.monitor
1: alsa_output.usb-Generic_USB_Audio-00.HiFi_7_1__hw_Audio_1__sink.monitor
2: alsa_output.usb-Generic_USB_Audio-00.HiFi_7_1__hw_Audio__sink.monitor
3: alsa_input.usb-Generic_USB_Audio-00.HiFi_7_1__hw_Audio_2__source
4: alsa_input.usb-Generic_USB_Audio-00.HiFi_7_1__hw_Audio_1__source
5: alsa_output.pci-0000_0f_00.1.hdmi-stereo-extra2.monitor
6: blast.monitor
7: blast.monitor
8: blast.monitor
----------
Select the audio source:
[6]
----------
Your LAN ip addresses
0: 192.168.163.181
1: 172.17.0.1
2: 172.18.0.1
----------
Select the lan IP address for the stream:
[0]
----------
2024/01/22 05:40:02 starting the stream on port 9000 (configure your firewall if necessary)
2024/01/22 05:40:02 stream URI: http://192.168.163.181:9000/stream
2024/01/22 05:40:02 setting av1transport URI and playing
SOAP fault. Code: SOAP-ENV:Client | Explanation: UPnPError | Detail: <u:UPnPError xmlns:u="urn:schemas-upnp-org:control-1-0"><u:errorCode>501</u:errorCode><u:errorDescription>Action Failed</u:errorDescription></u:UPnPError>

But it works fine on AirPin Pro (Android).

Debug Info
----------
DLNA receivers
0: XBOX
----------
Select the DLNA device:
[0]
(*goupnp.MaybeRootDevice)(0xc000222690)({
 USN: (string) (len=85) "uuid:04b6a5f1-7921-462f-a28e-d2402bf16117::urn:schemas-upnp-org:service:AVTransport:1",
 Root: (*goupnp.RootDevice)(0xc000249400)({
  XMLName: (xml.Name) {
   Space: (string) (len=31) "urn:schemas-upnp-org:device-1-0",
   Local: (string) (len=4) "root"
  },
  SpecVersion: (goupnp.SpecVersion) {
   Major: (int32) 1,
   Minor: (int32) 0
  },
  URLBase: (url.URL) http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117,
  URLBaseStr: (string) (len=99) "http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117",
  Device: (goupnp.Device) Device ID uuid:04b6a5f1-7921-462f-a28e-d2402bf16117 : urn:schemas-upnp-org:device:MediaRenderer:1 (XBOX)
 }),
 Location: (*url.URL)(0xc000258870)(http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117),
 LocalAddr: (net.IP) (len=16 cap=16) 192.168.163.181,
 Err: (error) <nil>
})
([]*av1.AVTransport1) (len=1 cap=1) {
 (*av1.AVTransport1)(0xc000155280)({
  ServiceClient: (goupnp.ServiceClient) {
   SOAPClient: (*soap.SOAPClient)(0xc00014e0c0)({
    EndpointURL: (url.URL) http://192.168.163.141:2869/upnphost/udhisapi.dll?control=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:AVTransport,
    HTTPClient: (http.Client) {
     Transport: (http.RoundTripper) <nil>,
     CheckRedirect: (func(*http.Request, []*http.Request) error) <nil>,
     Jar: (http.CookieJar) <nil>,
     Timeout: (time.Duration) 0s
    }
   }),
   RootDevice: (*goupnp.RootDevice)(0xc000249c00)({
    XMLName: (xml.Name) {
     Space: (string) (len=31) "urn:schemas-upnp-org:device-1-0",
     Local: (string) (len=4) "root"
    },
    SpecVersion: (goupnp.SpecVersion) {
     Major: (int32) 1,
     Minor: (int32) 0
    },
    URLBase: (url.URL) http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117,
    URLBaseStr: (string) (len=99) "http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117",
    Device: (goupnp.Device) Device ID uuid:04b6a5f1-7921-462f-a28e-d2402bf16117 : urn:schemas-upnp-org:device:MediaRenderer:1 (XBOX)
   }),
   Location: (*url.URL)(0xc000258870)(http://192.168.163.141:2869/upnphost/udhisapi.dll?content=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117),
   Service: (*goupnp.Service)(0xc00015a218)(Service ID urn:upnp-org:serviceId:AVTransport : urn:schemas-upnp-org:service:AVTransport:1),
   localAddr: (net.IP) <nil>
  }
 })
}
(interface {}) <nil>
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation" xmlns:microsoft="urn:schemas-microsoft-com:WMPDMR-1-0" xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11">
        <specVersion>
                <major>1</major>
                <minor>0</minor>
        </specVersion>
        <device>
                <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType><friendlyName>XBOX</friendlyName><modelName>Xbox One</modelName><modelDescription>Digital Media Renderer</modelDescription><manufacturer>Microsoft Corporation</manufacturer><manufacturerURL>https://www.microsoft.com</manufacturerURL><modelURL>https://xbox.com</modelURL>
                <UDN>uuid:04b6a5f1-7921-462f-a28e-d2402bf16117</UDN>
                <df:X_containerId>{BAC3F6A5-E593-4E2E-B826-5725CB9603BB}</df:X_containerId><dlna:X_DLNACAP xmlns:dlna="urn:schemas-dlna-org:device-1-0"></dlna:X_DLNACAP><dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC><pnpx:X_deviceCategory>MediaDevices</pnpx:X_deviceCategory><pnpx:X_hardwareId>VEN_0125&amp;DEV_0002&amp;REV_0001 VEN_0125&amp;DEV_0002</pnpx:X_hardwareId><iconList><icon><mimetype>image/jpeg</mimetype><width>120</width><height>120</height><depth>24</depth><url>/upnphost/udhisapi.dll?content=uuid:dca3a281-7337-498e-9014-2561d0a54475</url></icon><icon><mimetype>image/jpeg</mimetype><width>48</width><height>48</height><depth>24</depth><url>/upnphost/udhisapi.dll?content=uuid:91e0e209-b00f-4ff8-912d-5cc842524b63</url></icon><icon><mimetype>image/png</mimetype><width>120</width><height>120</height><depth>24</depth><url>/upnphost/udhisapi.dll?content=uuid:a5683b59-5e2b-49d6-8811-1c1d99ad0b61</url></icon><icon><mimetype>image/png</mimetype><width>48</width><height>48</height><depth>24</depth><url>/upnphost/udhisapi.dll?content=uuid:d5e98c59-7c5f-4ea9-8b52-6dfc72f43949</url></icon></iconList>
                <serviceList>
                        <service>
                                <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
                                <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
                                <controlURL>/upnphost/udhisapi.dll?control=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:RenderingControl</controlURL>
                                <eventSubURL>/upnphost/udhisapi.dll?event=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:RenderingControl</eventSubURL>
                                <SCPDURL>/upnphost/udhisapi.dll?content=uuid:b9949a04-e299-41aa-acbf-8fbee3a9099c</SCPDURL>
                        </service>
                        <service>
                                <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
                                <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
                                <controlURL>/upnphost/udhisapi.dll?control=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:AVTransport</controlURL>
                                <eventSubURL>/upnphost/udhisapi.dll?event=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:AVTransport</eventSubURL>
                                <SCPDURL>/upnphost/udhisapi.dll?content=uuid:22470209-9699-4ca0-8ac7-50f8f8e2a776</SCPDURL>
                        </service>
                        <service>
                                <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
                                <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
                                <controlURL>/upnphost/udhisapi.dll?control=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:ConnectionManager</controlURL>
                                <eventSubURL>/upnphost/udhisapi.dll?event=uuid:04b6a5f1-7921-462f-a28e-d2402bf16117+urn:upnp-org:serviceId:ConnectionManager</eventSubURL>
                                <SCPDURL>/upnphost/udhisapi.dll?content=uuid:296f3950-d3a1-41e5-b74e-041f6b33c5c5</SCPDURL>
                        </service>
                </serviceList>
        </device>
</root>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.