A lightweight REST API for managing GStreamer-based audio broadcasts.
Provides /start, /stop, and /status endpoints to control multicast or direct-stream audio pipelines.
- RESTful API for starting and stopping GStreamer audio pipelines
- PID-based process control (safe, avoids global
pkill) - Logging with timestamps to
/var/log/gstreamer_api.log - JSON responses for all endpoints
- Compatible with systemd or Docker deployment
sudo apt update
sudo apt install -y python3 python3-pip \
gstreamer1.0-tools \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-uglypip install -r requirements.txtStarts a new audio stream.
Request Body (JSON):
{
"source": "http://192.168.1.100:9000/train-automation/audios/alert.mp3",
"multicast_iface": "eno1",
"multicast_host": "239.193.0.52",
"multicast_port": 2100,
"volume": 10.0
}Response:
{
"status": "started",
"urlAddress": "http://192.168.1.100:9000/train-automation/audios/alert.mp3"
}Stops the currently active stream.
Response:
{
"status": "stopped",
"urlAddress": "http://192.168.1.100:9000/train-automation/audios/alert.mp3"
}If there’s no active stream:
{
"status": "no-active-stream",
"urlAddress": null
}Checks if a stream is currently active.
Response (playing):
{
"status": "playing",
"urlAddress": "http://192.168.1.100:9000/train-automation/audios/alert.mp3"
}Response (idle):
{
"status": "idle",
"urlAddress": null
}# Start a stream
curl -X POST http://localhost:8081/start \
-H "Content-Type: application/json" \
-d '{"source":"http://192.168.1.100:9000/train-automation/audios/test.mp3"}'
# Check status
curl http://localhost:8081/status
# Stop the stream
curl -X POST http://localhost:8081/stopAll activity is logged at:
/var/log/gstreamer_api.log
Typical entries:
2025-10-13 14:10:21 [INFO] Starting stream: gst-launch-1.0 souphttpsrc ...
2025-10-13 14:10:22 [INFO] GStreamer process started (PID=1810)
2025-10-13 14:12:08 [INFO] Stopped GStreamer process (PID=1810)
python3 app.py
Then open:
➡️ http://localhost:8081/status
Create a service file at /etc/systemd/system/audio-broadcast.service:
[Unit]
Description=RRAS Audio Broadcast API
After=network.target
[Service]
ExecStart=/usr/bin/python3 /opt/audio-broadcast-api/app.py
WorkingDirectory=/opt/audio-broadcast-api
Restart=always
User=root
StandardOutput=file:/var/log/gstreamer_api.log
StandardError=file:/var/log/gstreamer_api.log
[Install]
WantedBy=multi-user.targetThen enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable audio-broadcast.service
sudo systemctl start audio-broadcast.servicecurl http://localhost:8081/Response:
{
"service": "RRAS Audio Broadcast API",
"version": "1.2"
}This project is licensed under the MIT License. See the license file for details.
Please use the Issue > New Issue button to submit issues, feature requests or support issues directly to me. You can also send an e-mail to akin.bicer@outlook.com.tr.