{"id":48900275,"url":"https://github.com/tomerlichtash/defcon-webcam","last_synced_at":"2026-04-16T14:43:12.270Z","repository":{"id":343344612,"uuid":"1176957656","full_name":"tomerlichtash/defcon-webcam","owner":"tomerlichtash","description":"Real-time camera surveillance system for Raspberry Pi with live MJPEG streaming, automatic day/night mode switching, configurable camera presets, and integration with Israel's Home Front Command alert system.","archived":false,"fork":false,"pushed_at":"2026-03-09T23:06:39.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-10T05:19:07.788Z","etag":null,"topics":["alerts","defcon","ffmpeg","iot","mjpg-streamer","pikud-haoref","raspberry-pi","surveillance-camera","twitter-bot","webcam"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomerlichtash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-09T14:51:27.000Z","updated_at":"2026-03-09T23:06:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tomerlichtash/defcon-webcam","commit_stats":null,"previous_names":["tomerlichtash/defcon-webcam"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tomerlichtash/defcon-webcam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomerlichtash%2Fdefcon-webcam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomerlichtash%2Fdefcon-webcam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomerlichtash%2Fdefcon-webcam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomerlichtash%2Fdefcon-webcam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomerlichtash","download_url":"https://codeload.github.com/tomerlichtash/defcon-webcam/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomerlichtash%2Fdefcon-webcam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31891038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alerts","defcon","ffmpeg","iot","mjpg-streamer","pikud-haoref","raspberry-pi","surveillance-camera","twitter-bot","webcam"],"created_at":"2026-04-16T14:43:10.122Z","updated_at":"2026-04-16T14:43:12.265Z","avatar_url":"https://github.com/tomerlichtash.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DefconCam\n\nCamera surveillance system running on a Raspberry Pi with a Logitech BRIO webcam. Streams live video with on-screen overlays, automatically switches between day/night modes, monitors Israeli Home Front Command (Pikud HaOref) missile alerts for Gush Dan, and posts snapshots to Twitter/X and Telegram during alerts.\n\n## Features\n\n- **Live MJPEG stream** on port 8080 via mjpg-streamer + ffmpeg\n- **Camera presets**: day (manual exposure), night (auto exposure, high gain), indoor\n- **Configurable settings**: resolution (640x480 / 720p / 1080p), rotation (0/90/180/270), FPS, brightness, zoom\n- **OSD overlay**: DEFCON status, current settings, timestamp (Exo 2 font)\n- **Auto day/night switching** based on calculated sunrise/sunset for Tel Aviv (with configurable offset)\n- **Pikud HaOref alert monitoring** with fuzzy city matching for Gush Dan\n- **DEFCON states**: DEFCON 5 (idle, blue), DEFCON 4 (preemptive, green), DEFCON 2 (incoming missiles, red)\n- **Twitter/X integration**: posts camera snapshots on DEFCON 2 alerts\n- **Telegram integration**: sends camera snapshots to a Telegram group on DEFCON 2 alerts\n- **Manual publish**: publish snapshots to selected targets (Telegram, Twitter) from the web UI\n- **Persistent alert state**: survives service restarts\n- **Web control panel** on port 8081 with live system monitoring\n\n## Project Structure\n\n    defcon-cam/\n    ├── bin/                    # Executable scripts\n    │   ├── mjpg-ctl           # Main control script (presets, launcher generation)\n    │   ├── mjpg-rotated.sh    # Auto-generated ffmpeg pipeline + mjpg-streamer\n    │   ├── mjpg-auto          # Sunrise/sunset day/night auto-switcher (cron)\n    │   ├── mjpg-alert         # Alert monitor orchestrator\n    │   └── mjpg-web           # Web control panel server (port 8081)\n    ├── lib/                   # Shared Python modules\n    │   ├── config.py          # Constants, config file parsing\n    │   ├── state.py           # DEFCON state persistence and OSD display\n    │   ├── oref.py            # Pikud HaOref API client\n    │   ├── camera.py          # Snapshot helpers\n    │   ├── twitter.py         # Twitter/X posting\n    │   ├── telegram.py        # Telegram Bot API posting\n    │   └── sysinfo.py         # System info for web UI\n    ├── templates/\n    │   └── index.html         # Web UI template\n    ├── static/\n    │   └── fonts/             # Exo 2 font (used in web UI and OSD)\n    ├── tests/\n    │   └── test_alert.py      # Unit tests (61 tests)\n    ├── systemd/               # Service unit files\n    └── config/                # Persisted camera settings\n\n## External Config (not in repo)\n\n- `/etc/mjpg-streamer.conf` - Camera settings (mode, rotation, resolution, brightness, fps, zoom)\n- `/etc/mjpg-twitter.conf` - Twitter API credentials\n- `/etc/mjpg-telegram.conf` - Telegram bot token and chat ID\n\n## Dependencies\n\n### System packages\n\n- `ffmpeg` - video processing and OSD overlay\n- `mjpg-streamer` - MJPEG HTTP streaming (compiled with input_file plugin)\n- `v4l2-utils` - camera control (v4l2-ctl)\n- `curl` - snapshot capture\n- `gitleaks` - pre-commit secret scanning\n\n### Python packages\n\n- `tweepy` - Twitter API client\n\n### Hardware\n\n- Raspberry Pi (tested on aarch64)\n- Logitech BRIO webcam (or compatible UVC camera at /dev/video0)\n\n## Setup\n\n1. Install dependencies:\n\n       sudo apt install ffmpeg v4l2-utils curl\n       pip3 install tweepy\n\n2. Symlink scripts:\n\n       sudo ln -sf ~/defcon-cam/bin/mjpg-ctl /usr/local/bin/mjpg-ctl\n       sudo ln -sf ~/defcon-cam/bin/mjpg-rotated.sh /usr/local/bin/mjpg-rotated.sh\n       sudo ln -sf ~/defcon-cam/bin/mjpg-auto /usr/local/bin/mjpg-auto\n       sudo ln -sf ~/defcon-cam/bin/mjpg-alert /usr/local/bin/mjpg-alert\n       sudo ln -sf ~/defcon-cam/bin/mjpg-web /usr/local/bin/mjpg-web\n\n3. Symlink and enable services:\n\n       sudo ln -sf ~/defcon-cam/systemd/*.service /etc/systemd/system/\n       sudo systemctl daemon-reload\n       sudo systemctl enable mjpg-streamer mjpg-alert mjpg-web\n\n4. Create Twitter config:\n\n       sudo tee /etc/mjpg-twitter.conf \u003c\u003c CONF\n       API_KEY=\"your_key\"\n       API_SECRET=\"your_secret\"\n       ACCESS_TOKEN=\"your_token\"\n       ACCESS_SECRET=\"your_token_secret\"\n       CONF\n\n5. Create Telegram config:\n\n       sudo tee /etc/mjpg-telegram.conf \u003c\u003c CONF\n       BOT_TOKEN=\"your_bot_token\"\n       CHAT_ID=\"your_chat_id\"\n       CONF\n\n6. Set up auto day/night cron:\n\n       crontab -e\n       # Add: */15 * * * * /usr/local/bin/mjpg-auto --quiet \u003e\u003e /tmp/mjpg-auto.log 2\u003e\u00261\n\n7. Generate launcher and start:\n\n       mjpg-ctl day\n\n## Usage\n\n    mjpg-ctl day|night|indoor       # Switch mode\n    mjpg-ctl rotate 0|90|180|270    # Set rotation\n    mjpg-ctl res low|mid|high       # Set resolution\n    mjpg-ctl bright 0-100           # Set brightness\n    mjpg-ctl fps 5-30               # Set framerate\n    mjpg-ctl zoom 100-500           # Set zoom\n    mjpg-ctl status                 # Show current settings\n\n## Testing\n\n    python -m unittest discover -s tests -v\n\n## Alert Monitoring\n\nWatches the Pikud HaOref API for alerts matching Gush Dan cities using fuzzy substring matching:\n\n- גבעתיים (Givatayim)\n- רמת גן (Ramat Gan)\n- תל אביב (Tel Aviv)\n- בני ברק (Bnei Brak)\n\nState transitions:\n\n    DEFCON 5 (idle) ──preemptive──\u003e DEFCON 4 (alert incoming)\n    DEFCON 5 (idle) ──actual──────\u003e DEFCON 2 (incoming missiles)\n    DEFCON 4 ─────────actual──────\u003e DEFCON 2 (incoming missiles)\n    DEFCON 2 ─────────ended───────\u003e DEFCON 5 (idle)\n    DEFCON 4 ─────────ended───────\u003e DEFCON 5 (idle)\n\nOn DEFCON 2, after a 15-second confirmation delay, snapshots are posted to Twitter and Telegram.\n\nState is persisted to `/tmp/mjpg-alert-state` so restarts don't lose DEFCON status.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomerlichtash%2Fdefcon-webcam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomerlichtash%2Fdefcon-webcam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomerlichtash%2Fdefcon-webcam/lists"}