Skip to content

Latest commit

ย 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ธ Termux_WebCameraStream

Stream your Android phone's camera to any device over WiFi with real-time controls.

Turn your old Android phone into a wireless IP camera! This project creates a web-based camera streaming server that runs entirely in Termux, allowing you to view and control your phone's camera from any browser on your local network.


โœจ Features

  • ๐ŸŒ Web-Based Interface - View and control from any device (PC, tablet, another phone)
  • ๐Ÿ“ฑ Browser Capture Mode - High FPS streaming (20-30 FPS) using the phone's native camera API
  • ๐Ÿ“ท Termux Capture Mode - Fallback mode using termux-camera-photo (lower FPS but always works)
  • โšก Real-Time Settings - Change quality, resolution, zoom, rotation, and mirror on the fly
  • ๐ŸŒ“ Dark/Light Theme - Easy on the eyes, day or night
  • ๐ŸŽฅ Recording - Save streams as MJPEG files
  • ๐Ÿ“ธ Snapshots & Burst - Capture still images with one click
  • โŒจ๏ธ Keyboard Shortcuts - Space for snapshot, F for fullscreen
  • ๐Ÿ“ฆ Download ZIP - Download all recordings at once
  • ๐Ÿ“ฑ Mobile Responsive - Works great on phones and desktops

๐Ÿš€ Quick Start

Prerequisites

  1. Install Termux from F-Droid (NOT Google Play - that version is outdated)
  2. Install Termux:API from F-Droid

Installation

# Update packages
pkg update && pkg upgrade -y

# Install required packages
pkg install python termux-api -y

# Install Python dependencies
pip install Pillow

# Clone the repository
git clone https://github.com/HoomanJCode/Termux_WebCameraStream.git
cd Termux_WebCameraStream

# Run the server
python server.py

Usage

  1. Start the server on your phone:

    python server.py
  2. Option A: High FPS Browser Mode (Recommended)

    • On your phone's browser, open: http://localhost:8080/capture
    • Grant camera permission when prompted
    • On your PC browser, open: http://[PHONE_IP]:8080
    • Switch capture mode to "Browser Camera" in the sidebar
    • Enjoy 20-30 FPS streaming!
  3. Option B: Termux Mode (Fallback)

    • Just open http://[PHONE_IP]:8080 on any device
    • Uses termux-camera-photo (~1 FPS but no browser needed on phone)

Finding Your Phone's IP

# In Termux:
ifconfig wlan0 | grep 'inet ' | awk '{print $2}'

๐ŸŽฎ Controls

Web Interface

Control Description
Capture Mode Switch between Browser (fast) and Termux (compatible)
Resolution 320x240 to 1280x720 (higher = more detail, slower)
Quality JPEG compression 10-100% (lower = faster, higher = better)
Zoom Digital zoom 1.0x - 5.0x
Rotation 0ยฐ, 90ยฐ, 180ยฐ, 270ยฐ
Mirror H/V Flip image horizontally/vertically
Flash Toggle flashlight (Termux mode only)

Action Buttons

Button Action
๐Ÿ“ท Snapshot Save current frame as JPEG
๐Ÿ“ธ Burst (5) Take 5 rapid snapshots
โบ Record Start recording MJPEG video
โน Stop Stop recording and save
๐Ÿ’ก Flash Toggle LED flash
โ›ถ Fullscreen Enter fullscreen mode
๐ŸŒ“ Theme Switch dark/light theme
๐Ÿ“ฆ Download ZIP Download all recordings

Keyboard Shortcuts

Key Action
Space Take snapshot
F Toggle fullscreen

๐Ÿ“ Project Structure

Termux_WebCameraStream/
โ”œโ”€โ”€ server.py              # Main HTTP server with WebSocket support
โ”œโ”€โ”€ camera.py              # Termux camera capture module
โ”œโ”€โ”€ settings.py            # JSON-based settings management
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ index.html         # Main web interface (PC viewer)
โ”‚   โ”œโ”€โ”€ capture.html       # Phone camera capture page
โ”‚   โ”œโ”€โ”€ style.css          # Dark/light theme styles
โ”‚   โ””โ”€โ”€ script.js          # Client-side logic & API calls
โ”œโ”€โ”€ camera_settings.json   # Persistent settings file
โ””โ”€โ”€ recordings/            # Saved MJPEG recordings

๐Ÿ”ง Configuration

Command Line Options

python server.py -p 8080        # Custom port (default: 8080)
python server.py -s myconf.json  # Custom settings file

Default Settings

Settings are stored in camera_settings.json and can be edited manually:

{
    "camera_id": 0,
    "width": 640,
    "height": 480,
    "quality": 80,
    "rotation": 0,
    "zoom": 1.0,
    "mirror_h": false,
    "mirror_v": false,
    "show_timestamp": false,
    "show_grid": false,
    "motion_detection": false,
    "motion_threshold": 30
}

๐Ÿ› Known Issues

โš ๏ธ Black Screen Flicker in Browser Mode

Status: Open - Help Wanted!

When changing the quality setting in Browser mode, the video stream sometimes shows a black screen or flickers. This issue is being actively investigated.

What we know:

  • Only occurs in Browser capture mode
  • Triggered by quality setting changes
  • May be related to canvas rendering or JPEG encoding timing
  • The stream recovers after a few seconds

If you can help fix this:

  • Check static/capture.html - the captureFrame() function
  • The issue may be in how toBlob() or toDataURL() handles quality changes
  • Could be a race condition between canvas updates and WebSocket sending
  • PRs are welcome! Please test on multiple Android versions

Workaround: Avoid changing quality while streaming, or refresh the /capture page after changing settings.


๐Ÿค Contributing

This project was created through vibe coding with DeepSeek - an AI-assisted development process. We welcome contributions from humans and AIs alike!

How to Contribute

  1. Report bugs - Open an issue with:

    • Android version
    • Termux version
    • Steps to reproduce
    • Console logs (F12 in browser)
  2. Fix the black screen bug - See Known Issues above

  3. Add features - Ideas welcome:

    • Audio streaming
    • PTZ controls
    • Motion detection alerts
    • Multiple camera support
    • RTSP/RTMP output
    • Docker support
    • Home Assistant integration
  4. Improve documentation - Better install guides, troubleshooting, etc.

Development Setup

# Fork and clone
git clone https://github.com/HoomanJCode/Termux_WebCameraStream.git
cd Termux_WebCameraStream

# Create a test environment
python -m venv venv
source venv/bin/activate  # On Termux, just use system python
pip install Pillow

# Run in debug mode
python server.py

๐Ÿ“œ Disclaimer

Privacy & Security

โš ๏ธ This server has NO authentication. Anyone on your local network can:

  • View your camera stream
  • Change camera settings
  • Take snapshots and recordings

Do NOT expose this server to the internet. Only use it on trusted local networks. The server binds to 0.0.0.0 by default, meaning it's accessible to all devices on your WiFi.

Legal

  • Respect privacy laws in your jurisdiction
  • Do not use for surveillance without consent
  • You are responsible for how you use this software
  • This project is provided AS IS without warranty

Compatibility

  • Tested on Android 10-14 with Termux from F-Droid
  • Browser capture requires a modern browser (Chrome/Firefox)
  • Termux capture mode requires termux-camera-photo from Termux:API
  • Not all Android devices support all camera features

๐ŸŽฏ Use Cases

  • Baby monitor - Keep an eye on your little one
  • Pet cam - Watch your pets while away
  • Security camera - Monitor your room/garage
  • 3D printer monitor - Check your prints remotely
  • Timelapse photography - Record long processes
  • Webcam for PC - Use your phone as a high-quality webcam
  • IoT integration - Stream to Home Assistant, Node-RED, etc.

๐Ÿ“„ License

MIT License - See LICENSE file for details.


๐Ÿ™ Acknowledgments

  • DeepSeek AI - Primary development assistant (vibe coding ๐Ÿค–)
  • Termux Team - Amazing terminal emulator for Android
  • Pillow - Python imaging library
  • All contributors - Those who help fix bugs and add features

๐ŸŒŸ Star History

If this project helps you, please โญ star it on GitHub! It helps others find it and motivates further development.


Made with โค๏ธ and โ˜• in Termux, powered by DeepSeek AI

"Vibe coding is real, and it's spectacular" - Someone, probably

About

Turn your old Android phone into a wireless IP camera! This project creates a web-based camera streaming server that runs entirely in Termux, allowing you to view and control your phone's camera from any browser on your local network.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages