JvanKatwijk / dab-cmdline

DAB decoding library with example of its use
GNU General Public License v2.0
57 stars 29 forks source link

dab-library within MPD plugin #86

Open macmpi opened 2 years ago

macmpi commented 2 years ago

Hi, As MPD is one of the most versatile audio player solution, I was wondering if there is any plan to build some sort of MPD source plugin so that DAB/DAB+ can be smoothly integrated in many MPD-based solutions. Thoughts?

JvanKatwijk commented 2 years ago

Well, nothing is impossible, but I am not familiar with mdp. So, does it take aac frames or audio samples as input, if so, it is quite straightforward since variants that generate that type of output exist

On Tue, Sep 6, 2022, 2:40 PM macmpi @.***> wrote:

Hi, As MPD https://www.musicpd.org/ is one of the most versatile audio player solution, I was wondering if there is any plan to build some sort of MPD source plugin https://mpd.readthedocs.io/en/latest/plugins.html#input-plugins so that DAB/DAB+ can be smoothly integrated in many MPD-based solutions. Thoughts?

— Reply to this email directly, view it on GitHub https://github.com/JvanKatwijk/dab-cmdline/issues/86, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCPHQGKPQPUULZD5BEYHN3V443SPANCNFSM6AAAAAAQFZGUYI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

macmpi commented 2 years ago

Yes MPD deals with most formats, including plain samples. It does manages playlists also and all sort of tags/metadata, so scanned DAB radio channels could easily be filled in such playlist to that any MPD client (GUI / cmdline) would seamlessly handle channel selection. There is a huge range of GUI clients available on any platforms.

Lamarqe commented 1 year ago

I use dab-cmdline in combination with MPD. The bridge between both is created with TvHeadend. You need to create a pipe input mux for each radio station in TvHeadend. Details regarding this solution can be found here: https://tvheadend.org/issues/3309

You can use the TVHeadend playlist directly in MPD. An excerpt from my playlist:

#EXTM3U
#EXTINF:-1,ANTENNE BAYERN
http://localhost:9981/stream/channelid/508067241?profile=pass

The Pipe Mux for this station uses the following URL :

pipe:///usr/local/dab-cmdline/example-4/build/runscript.sh 11D "ANTENNE BAYERN"

The helper script contents look like this:

#!/bin/bash
/usr/local/dab-cmdline/example-4/build/dab-rtlsdr-4 -M 1 -B "BAND III" -C $1 -P "$2" -G 80  | ffmpeg -i pipe: -acodec copy -metadata service_provider=DAB+ -metadata service_name="$2" -vn -f mpegts -mpegts_service_type digital_radio -nostats -loglevel 0 pipe:1
vale-max commented 1 year ago

@Lamarqe Are you sure the audio is decoded correctly, e.g. the pitch is correct, or the tempo? As far as I remember MPD uses ffmpeg to decode the audio, and ffmpeg does not support correctly the DAB+ AAC frames that have 960 rather than 1024 samples. I tried repeatedly to have this issue fixed in ffmpeg but for some reason this bug keeps being ignored: https://trac.ffmpeg.org/ticket/1407

Lamarqe commented 1 year ago

Yes, I am. I use this setup every day. 😄

I had initial problems with the tempo when I used example-3. I tried to work around with some ffmpeg parameter to manually correct it, but the results were unacceptable.

As soon as I switchted to example 4 ("No sound decoding takes place. The MP2 frames (in case of DAB) and the AAC frames (in case of DAB+) are just emitted into a file or to stdout."), the problems disappeared.

Interistringly, my trigger to switch to example 4 was the CPU usage. Example 4 uses far less CPU. So this switch solved two problems at the same point in time.

Lamarqe commented 1 year ago

One more comment: Example 4 avoids any re-encoding within dab-cmdline. The ffmpeg command line in my tvheadend helper script also does not do any re-encoding. The only thing it does, is to wrap the dab-cmdline stream into an mpegts envelope. This is the prerequisite for tvheadend which does the http serving (which I then again use in mpd as a stream URL). Bottom line: No re-encoding at all. At the end, mpd streams the original DAB+ stream (in my case via pulseaudio to chromecast and chromecast does the decoding).

Lamarqe commented 12 months ago

@vale-max I recently changed my setup and then also faced issues with streams that could not be processed due to the ffmpeg incompatibility you mentioned.

This ended up in replacing the ffmpeg command line in my helper script with a VLC one:

#!/bin/bash
/usr/bin/dab-rtlsdr-4 -M 1 -B "BAND III" -C $1 -P "$2" -G 80 2>/dev/null | cvlc - --sout "#transcode{acodec=mpga,channels=2,rate=44100,ab=320}:std{access=file,mux=ts,tsid=1,dst=-}" -q --intf dummy vlc:quit 

So instead of handing over the stream as-is to tvheadend, it is getting processed and converted before by VLC. Apparently, libVLC does not have this problem.

Lamarqe commented 3 months ago

I implemented an application which can be integrated with MPD: https://github.com/Lamarqe/mpdcast-dab