A real-time Django-powered backend for the Retro Radio project using Django Channels, Redis, and WebSockets. Audio is streamed via Icecast + FFmpeg, simulating a GTA-style retro radio station.
- Python 3.10.11
- Django 5.1
- Django Channels
- Redis (Cloud or Local)
- Daphne (ASGI server)
- FFmpeg + Icecast2 (for audio streaming)
git clone https://github.com/Y0ur-Team/Retro-Radio-Backend.git
cd retro-radio-backendpython -m venv venv
source venv/bin/activate # On Linux/Mac
venv\Scripts\activate # On Windowspip install -r requirements.txtAt the root of the project, create a .env file:
and just put hte real values on hte hte .env
python manage.py migrateat port 80 as we will use port 8000 for WS server
python manage.py runserver 0.0.0.0:80it will use port 80
Using Daphne (production-ready):
daphne retro_radio.asgi:applicationOr Uvicorn (optional):
uvicorn retro_radio.asgi:application --reload- Download from: https://icecast.org/download.php#windows
- Extract the folder
icecast_win32_2.4.4and runicecast.exe - Ensure port
8001is open and streaming is enabled inicecast.xml.
- Download from: https://ffmpeg.org/download.html
- Add the
ffmpeg/binfolder to your system PATH (for terminal access).
Place your MP3 file (e.g. test.mp3) in the same directory as ffmpeg.exe.
Run this command to loop-broadcast the track:
ffmpeg -re -stream_loop -1 -i test.mp3 -content_type audio/mpeg -f mp3 icecast://source:retroradio@localhost:8001/stream🧠 This continuously sends test.mp3 to Icecast, which serves it on:
http://localhost:8001/stream
-
Download & Place the Required Tools/Resources:
- 🔻 Icecast
- 🔻 FFmpeg
- Place
NonStopPopFMHostedbyCaraGTA5.mp3manually in the correct folder - Click
NonStopPopFMHostedbyCaraGTA5.mp3to Download !
-
Extract and place them in the correct folders:
radiostream/ ├── Icecast/ ├── ffmpeg-master-latest-win64-gpl/bin/NonStopPopFMHostedbyCaraGTA5.mp3 └── ffmpeg-master-latest-win64-gpl/ -
🎵 Place your audio file as:
radiostream/ffmpeg-master-latest-win64-gpl/bin/NonStopPopFMHostedbyCaraGTA5.mp3 -
▶️ Run this script to launch Icecast + FFmpeg stream:start_radio_GTA5.bat
-
✅ The station will stream continuously on: http://localhost:8001/stream Tune into
100.7 MHzin your app to listen!
-
URL format:
ws://localhost:8000/ws/<frequency>/?token=<session_id> -
If frequency is
100.7, server will automatically streamhttp://localhost:8001/stream. -
The
tokenis required (acts as session ID).
Open test.html in your browser to test WebSocket messages and auto-play stream.
You will hear "NonStopPopFM by Cara" on 100.7 MHz.
Open test.html in your browser to manually test WebSocket functionality.
Configure your REDIS_URL in .env as:
redis://default:<password>@<host>:<port>
Install Memurai (on Windows) or Redis (on Linux/macOS), then use:
REDIS_URL=redis://localhost:6379
collect static with this command
python manage.py collectstatic
retro_radio/
│
├── retro_radio/
│ ├── settings.py
│ ├── asgi.py ← ASGI application entry
│ └── urls.py
│
├── core/
│ ├── consumers.py ← WebSocket consumer
│ ├── routing.py ← WebSocket URL routing
│ └── models.py
│
├── .env ← Contains Redis URL & secret key
├── manage.py
└── requirements.txt
─── index.html ← for testing hte api ofc