Traffic Reducer supports two video source modes — YouTube live and local MP4 — switchable at runtime without restarting the Flask server. The active source is shared across all browser sessions; changing it from one tab or via the API immediately affects every connected client.Documentation 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.
YouTube mode
Whenmode is set to 'youtube', the server uses yt-dlp to resolve the direct stream URL from the configured channel:
yt-dlp attempts extraction with multiple player clients in the following order:
/video_feed MJPEG stream.
Failure and reconnection behaviour:
- If the stream drops or
yt-dlpfails to resolve the URL, the server enters a 60-second cooldown before retrying automatically. - After 3 consecutive failures (when a local video file is available), the placeholder frame message changes to “YouTube no responde — cambia a Video local”, prompting you to switch sources.
- TLS handshake errors and socket reset messages that appear in the terminal during this period are handled by the reconnection logic and are safe to ignore.
Local video mode
Whenmode is set to 'local', the server reads frames directly from:
- The video loops automatically when the file ends — no manual restart is needed.
-
Playback runs at 0.5× speed by default (half real-time). This default is set by
LOCAL_VIDEO_SPEEDinapp.py: -
The playback speed can be changed at runtime via
POST /set_speedwithout switching modes.
modal-pick-local option in the source selection modal are both automatically disabled if traffic_dron_view.mp4 is not found on disk at startup. The server reports availability through GET /source_status using the has_local field.
Switching sources via the UI
Open the source switcher
In the camera feed card header, locate the EN VIVO and VIDEO LOCAL buttons on the right side of the card.
Click your target source
Click EN VIVO to switch to YouTube live, or VIDEO LOCAL to switch to the local MP4. The badge in the top-left of the card updates immediately to
● EN VIVO or ● VIDEO LOCAL.set_mode() on the server closes any open capture device or FFmpeg subprocess, resets last_yolo_data and yolo_cache to clear stale detection state, and replaces the current frame with a transition placeholder (e.g., “Conectando al stream en vivo…”) until the new source produces its first decoded frame.
Switching sources via the API
You can also switch sources programmatically usingPOST /set_source:
Adjusting local video playback speed
UsePOST /set_speed to change the local video playback multiplier at runtime:
Checking current source status
mode is one of "youtube", "local", or "idle". has_local is true only if traffic_dron_view.mp4 exists on disk at the path checked during server startup.
The server always starts in
idle mode regardless of previous session state. The source selection modal is shown automatically on page load when mode is "idle". The selected mode persists in memory until changed via the UI or API, or until the server restarts.