mirror of
https://github.com/jketterl/openwebrx.git
synced 2026-02-27 10:04:20 +01:00
DAB+ audio: WAV default for all sample rates (24/32/48 kHz), stereo input fix
- Default: dablin -w so ffmpeg reads rate and channels from WAV header; all DAB+ services (24/32/48 kHz, mono/stereo) play at correct speed. - Fallback: OPENWEBRX_DAB_USE_WAV=0 uses PCM path with OPENWEBRX_DAB_INPUT_RATE (24000|32000|48000). - Fix: treat dablin output as stereo (-ac 2); mono caused consistently slow playback. - Optional OPENWEBRX_DAB_CAPTURE_RAW=1 for raw PCM capture (PCM path). - README-FORK.md: document env vars and behaviour.
This commit is contained in:
parent
8e76b89b22
commit
5206e5b0ae
30
README-FORK.md
Normal file
30
README-FORK.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# dom-robinson/openwebrx fork – DAB+ sample rate fix
|
||||
|
||||
This is a clone of [dom-robinson/openwebrx](https://github.com/dom-robinson/openwebrx) with branch **feature/dab-audio-fix** containing improvements over upstream [jketterl/openwebrx PR #419](https://github.com/jketterl/openwebrx/pull/419): **Fix DAB+ audio sample rate issues using ffmpeg resampling**.
|
||||
|
||||
## What’s in this branch
|
||||
|
||||
- **owrx/dab/dablin.py** – DAB+ audio fix with **automatic handling of all sample rates (24/32/48 kHz)** and mono/stereo:
|
||||
- **Default (WAV path):** `dablin -w` so ffmpeg reads sample rate and channel count from the WAV header; resample to 48 kHz stereo. All DAB+ services play at correct speed without configuration.
|
||||
- **Fallback (PCM path):** Set `OPENWEBRX_DAB_USE_WAV=0` and optionally `OPENWEBRX_DAB_INPUT_RATE=24000|32000|48000` if WAV causes issues. Optional `OPENWEBRX_DAB_CAPTURE_RAW=1` tees raw PCM to `/tmp/dablin_capture.raw` for analysis.
|
||||
- **Critical fix:** Treat dablin output as **stereo** (`-ac 2`) when using PCM; using mono caused consistently slow playback.
|
||||
- **docker/scripts/install-dependencies.sh** – Add `sox` to static packages.
|
||||
- **Dockerfile.hotfix** – Optional image that builds dablin from source and applies the dablin.py patch.
|
||||
|
||||
## Environment variables (optional)
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `OPENWEBRX_DAB_USE_WAV` | `1` | Use dablin WAV output so rate/channels are automatic. Set `0` to use PCM path with fixed rate. |
|
||||
| `OPENWEBRX_DAB_INPUT_RATE` | `32000` | Only when `OPENWEBRX_DAB_USE_WAV=0`: input rate 24000, 32000, or 48000. |
|
||||
| `OPENWEBRX_DAB_CAPTURE_RAW` | unset | Set to `1` to tee raw PCM to `/tmp/dablin_capture.raw` (PCM path only, for analysis). |
|
||||
|
||||
## Push this branch to the fork
|
||||
|
||||
From this directory, with GitHub auth set up:
|
||||
|
||||
```bash
|
||||
git push -u origin feature/dab-audio-fix
|
||||
```
|
||||
|
||||
After pushing, the fork on GitHub will list the branch and you can open or update a PR to jketterl/openwebrx, or build images from it.
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from pycsdr.modules import ExecModule
|
||||
from pycsdr.types import Format
|
||||
|
||||
|
|
@ -12,8 +13,30 @@ class DablinModule(ExecModule):
|
|||
)
|
||||
|
||||
def _buildArgs(self):
|
||||
# Use -w so dablin outputs WAV (with correct sample rate in header); ffmpeg then resamples to 48k
|
||||
return ["bash", "-c", "dablin -w -s {:#06x} | mbuffer -q -m 1M | ffmpeg -v error -i pipe:0 -f f32le -ar 48000 -ac 1 pipe:1".format(self.serviceId)]
|
||||
# Two paths:
|
||||
# 1) WAV (default): dablin -w so ffmpeg reads rate and channels from header → 24/32/48 kHz and mono/stereo all work.
|
||||
# 2) PCM: set OPENWEBRX_DAB_USE_WAV=0 and OPENWEBRX_DAB_INPUT_RATE=24000|32000|48000 if WAV causes issues.
|
||||
# Optional: OPENWEBRX_DAB_CAPTURE_RAW=1 tees raw PCM to /tmp/dablin_capture.raw (PCM path only).
|
||||
use_wav = os.environ.get("OPENWEBRX_DAB_USE_WAV", "1") != "0"
|
||||
if use_wav:
|
||||
dab_cmd = (
|
||||
"dablin -w -s {:#06x} | mbuffer -q -m 4M | "
|
||||
"ffmpeg -v error -probesize 4096 -analyzeduration 0 -f wav -i pipe:0 "
|
||||
"-af aresample=48000 -f f32le -ar 48000 -ac 2 pipe:1"
|
||||
).format(self.serviceId)
|
||||
else:
|
||||
rate = int(os.environ.get("OPENWEBRX_DAB_INPUT_RATE", "32000"))
|
||||
if rate not in (24000, 32000, 48000):
|
||||
rate = 32000
|
||||
dab_cmd = "echo {} > /tmp/dablin_rate.txt 2>/dev/null; dablin -p -s {:#06x}".format(rate, self.serviceId)
|
||||
if os.environ.get("OPENWEBRX_DAB_CAPTURE_RAW"):
|
||||
dab_cmd += " | tee >(dd of=/tmp/dablin_capture.raw bs=1M count=5 2>/dev/null)"
|
||||
dab_cmd += (
|
||||
" | mbuffer -q -m 4M | "
|
||||
"ffmpeg -v error -f s16le -ar {} -ac 2 -i pipe:0 "
|
||||
"-af aresample=48000 -f f32le -ar 48000 -ac 2 pipe:1"
|
||||
).format(rate)
|
||||
return ["bash", "-c", dab_cmd]
|
||||
|
||||
def setDabServiceId(self, serviceId: int) -> None:
|
||||
self.serviceId = serviceId
|
||||
|
|
|
|||
Loading…
Reference in a new issue