Most issues fall into four categories — stream connectivity, model loading, video capture, and performance. Check the terminal output first; Traffic Reducer logs prefixed messages such asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Xander44-4/traffic_reducer/llms.txt
Use this file to discover all available pages before exploring further.
[App], [TrafficCamera], and [ffmpeg] that usually point directly to the problem. The sections below cover each known issue with its symptoms and recommended fix.
TLS or Socket errors in the terminal
TLS or Socket errors in the terminal
Symptom: Lines like the following appear repeatedly in the terminal:Cause: YouTube stream network instability during the HLS connection managed by the
ffmpeg subprocess. These messages are printed by ffmpeg’s stderr drain thread and do not represent a crash.Fix: Ignore them. The processing loop in _process_stream() detects when the ffmpeg pipe terminates (self.yt_proc.poll() is not None) and automatically closes and re-opens the stream. If the stream stays down, the system enters a 60-second cooldown period (after all yt-dlp clients are exhausted) and then retries. No manual intervention is required.Video feed shows a dark placeholder frame
Video feed shows a dark placeholder frame
Symptom: The dashboard camera card shows the message
"Conectando al stream en vivo..." or "Stream no disponible — reintentando..." and the frame never updates to a live image.Cause: yt-dlp failed to resolve a direct stream URL from the YouTube link. This happens when the stream is offline, the URL has changed, or all six yt-dlp player clients (android, tv_simply, web, mweb, tv, android_vr) failed in sequence.Fix:- Check your internet connection.
-
Verify that
YOUTUBE_URLinapp.pyis still an active live stream. Open the URL in a browser to confirm. -
After 3 consecutive
yt-dlpfailures, the placeholder message changes to"YouTube no responde — cambia a Video local"(if a local file exists). Switch to local video mode via the dashboard or: -
If the issue persists, update
yt-dlpto the latest version, as YouTube regularly changes its extraction flow.
MODEL_PATH error on startup
MODEL_PATH error on startup
Symptom: The terminal shows:Cause: This path does not exist on other machines.Fix: Open Alternatively, construct the path dynamically relative to Restart the server after saving. If the model still fails to load, verify it was saved with a compatible scikit-learn version —
MODEL_PATH in app.py is hardcoded to an absolute Windows path from the original developer’s machine:traffic_app/app.py and replace MODEL_PATH with the correct absolute path to modelo_semaforo_ia.pkl on your system. For example:app.py:app.py tries both pickle.load and joblib.load automatically."Video local no encontrado" in the dashboard
"Video local no encontrado" in the dashboard
Symptom: The VIDEO LOCAL button is disabled in the dashboard. The Alternatively, point Restart the server after making the change —
/source_status endpoint returns "has_local": false. Calling /set_source with "mode": "local" returns HTTP 400: {"error": "Video local no encontrado en disco"}.Cause: The expected file traffic_app/static/traffic_dron_view.mp4 does not exist. This MP4 is not included in the git repository due to file size constraints.Fix: Place any drone-view or intersection traffic MP4 at that path:LOCAL_VIDEO_PATH in app.py to a different file on your machine before starting the server:LOCAL_VIDEO_EXISTS is evaluated once at startup.Slow performance / high CPU usage
Slow performance / high CPU usage
Symptom: Frame rate in the dashboard is low (choppy video), the
/stats endpoint is sluggish, or CPU usage is near 100%.Cause: YOLOv8 inference (_run_yolo()) is CPU-bound when no GPU is available. The default model yolov8m.pt (medium) is significantly heavier than the nano or small variants.Fix:-
Switch to a lighter model. Delete or rename
yolov8m.ptandyolov8s.ptfrom the project root. Placeyolov8n.pt(nano) there instead.app.pychecks foryolov8m.ptthenyolov8s.ptat startup; if neither exists, it falls back to"yolov8m.pt"which Ultralytics will auto-download. Name ityolov8m.ptto ensure it is picked up, or setYOLO_MODEL_PATHdirectly: -
Reduce inference image size. In
video_processor.py, the_run_yolo()method setsimgsz=640. Change this to416or320to reduce computation: - Install GPU-enabled PyTorch. If a CUDA-capable GPU is available, install the matching PyTorch build from pytorch.org and Ultralytics will automatically use it.
-
Increase local video speed. If using local video, the frame rate is gated by
local_speed. A higher speed value means fewer inference calls per real-time second:
"py" command not found
"py" command not found
Symptom:Cause: The README start command uses Make sure you are running the command from the project root directory (the folder that contains
py, which is a Windows Python Launcher shortcut not available on macOS or Linux.Fix: Use the standard python or python3 command instead:traffic_app/), not from inside traffic_app/ itself.Prediction always returns 0 (Norte)
Prediction always returns 0 (Norte)
Symptom: The This means no vehicles are being detected in any zone.Fix:
/predict endpoint always returns {"prediction": 0, ...} and the green light on the dashboard always shows Norte, regardless of the traffic on camera.Cause: All four zone counts are zero. The prediction logic in app.py returns 0 when sum(traffic_values) == 0:- Confirm a video source is active — check
GET /source_statusand switch to"youtube"or"local"if the mode is"idle". - Watch the terminal for
[TrafficCamera] URL obtenida(YouTube) orVideo local abierto(local) to confirm the stream opened successfully. - Check
/stats— ifnorte,sur,este, andoesteare all0while the feed is running, the zone polygons may not intersect with the vehicles in the frame. The four zones are defined as normalised polygon coordinates invideo_processor.pyand are calibrated for the bundled drone-view camera angle. - If you are using a different camera angle, reconfigure the zone polygons in the
self.zonesdictionary insideTrafficCamera.__init__()to match your field of view.
Flask port 5000 already in use
Flask port 5000 already in use
Symptom: The server fails to start with:Cause: Port 5000 is in use by another process. On macOS 12+, the AirPlay Receiver service binds to port 5000 by default.Fix — macOS: Open System Settings → General → AirDrop & Handoff and disable AirPlay Receiver.Fix — any OS: Change the port in Then access the dashboard and API at
app.py:http://127.0.0.1:5001 instead.