A high-performance, modular screen sharing application built with Python and OpenCV. Features a robust client-server architecture designed for professional use cases requiring efficient remote desktop viewing with minimal latency.
ScreenShare provides a reliable, cross-platform solution for remote screen viewing with enterprise-grade features. The application leverages multiple capture methodologies to ensure compatibility across diverse system configurations while maintaining optimal performance through configurable streaming parameters.
-
Multi-Display Support: Intelligent display detection with seamless switching between monitors
-
Adaptive Performance: Configurable frame rate and quality settings for network optimization
-
Cross-Platform Compatibility: Comprehensive support for Windows, Linux, and macOS environments
-
Resilient Architecture: Multiple fallback capture methods and automatic reconnection handling
-
Comprehensive Monitoring: Real-time performance metrics and connection statistics
-
Extensible Design: Modular codebase with clear separation between capture, encoding, and transmission layers
-
Python 3.7 or newer
-
pip package manager
-
Network connectivity between client and server systems
# Clone the repository
git clone https://github.com/Jiahong-Guan/Screenshare.git
cd Screenshare
# Install dependencies
pip install -r requirements.txtopencv-python- Computer vision operations and display managementmss- High-performance screen capture (primary method)pyautogui- Cross-platform mouse position trackingscreeninfo- Display configuration detectionPillow- Alternative image capture and processingcolorama- Enhanced terminal output formattingnumpy- Efficient array manipulation and image processing
Initialize the server component to begin listening for connections:
python server.pyConnect the client to the server from the system to be viewed:
python client.py --host=SERVER_IP_ADDRESSReplace SERVER_IP_ADDRESS with the IP address or hostname of the server system.
python server.py [options]Available Options:
| Option | Description | Default Value |
|---|---|---|
--host=HOST |
Network interface to bind | 0.0.0.0 (all interfaces) |
--port=PORT |
TCP port for incoming connections | 8080 |
--log-level=LEVEL |
Logging verbosity level | silent |
-l=LEVEL |
Short form for log level | silent |
Example Configuration:
python server.py --host=192.168.1.100 --port=9000 --log-level=infopython client.py [options]Available Options:
| Option | Description | Default Value |
|---|---|---|
--host=HOST |
Server address for connection | localhost |
--port=PORT |
Server port for connection | 8080 |
--log-level=LEVEL |
Logging verbosity level | silent |
-l=LEVEL |
Short form for log level | silent |
Example Configuration:
python client.py --host=192.168.1.100 --port=9000 --log-level=warning| Level | Description | Use Case |
|---|---|---|
| silent | No logging output | Production environments |
| critical | Critical errors only | Minimal debugging |
| error | Error conditions | Error monitoring |
| warning | Warning conditions | System monitoring |
| info | Informational messages | General operation |
| debug | Detailed debugging information | Development and troubleshooting |
| Key | Function | Description |
|---|---|---|
Q |
Quit | Terminate the application |
I |
Info Overlay | Toggle performance statistics display |
M |
Mouse Tracking | Toggle client mouse cursor display |
F |
Full Screen | Toggle full-screen display mode |
A |
Actual Size | Toggle 1:1 pixel display mode |
+ / = |
Zoom In | Increase display window size |
- |
Zoom Out | Decrease display window size |
R |
Reset Window Size | Reset window to default size |
1-9 |
Switch Displays | Switch between available display |
-
Automatic Display Detection: Supports complex multi-monitor configurations
-
Adaptive Capture Methods: Primary (MSS) with graceful fallbacks
-
Performance Configuration: Adjustable frame rate and compression quality
-
Command Processing: Real-time response to server control commands
The client implements a sophisticated capture pipeline:
-
Display Detection: Automatically identifies available displays using multiple detection methods
-
Screen Capture: Employs MSS as the primary capture mechanism with PIL fallback
-
Frame Processing: Optimizes image data through JPEG encoding with configurable quality
-
Network Transmission: Implements efficient TCP socket communication with metadata framing
-
Command Handling: Processes server-side control commands in real-time
The server provides a comprehensive viewing experience:
-
Connection Management: Listens for and maintains client connections
-
Frame Reception: Receives and reconstructs frame data with error handling
-
Display Management: Renders frames with configurable viewing options
-
User Interaction: Processes keyboard input for display control
-
Performance Monitoring: Tracks and displays connection statistics
-
Frame Rate Adjustment: Reduce FPS settings for bandwidth-constrained networks
-
Quality Configuration: Lower JPEG quality for improved transmission speed
-
Network Infrastructure: Prefer wired Ethernet connections for stable performance
-
Resource Allocation: Ensure adequate CPU resources for encoding/decoding
-
Display Configuration: Match client and server display resolutions where possible
-
Background Processes: Minimize competing system resource consumption
Symptoms: Connection failures or timeouts
-
Verification Steps:
-
Confirm network connectivity between systems
-
Validate firewall configuration for specified port
-
Verify server IP address and port configuration
-
Check for conflicting applications using the same port
-
Symptoms: Incorrect or missing display detection
-
Resolution Steps:
-
Install required dependencies:
pip install mss screeninfo -
Execute with appropriate system privileges
-
Verify display driver functionality
-
Check system-specific display configuration
-
Symptoms: Low frame rates or high latency
- Optimization Steps:
-
Adjust client quality setting:
self.quality = 70 -
Reduce frame rate:
self.fps = 5 -
Monitor network bandwidth utilization
-
Evaluate system resource availability
Symptoms: Missing mouse cursor or control problems
- Diagnostic Steps:
-
Verify pyautogui installation
-
Use
Mkey to toggle mouse display -
Check client-server command communication
-
Review application logs for error messages
We welcome contributions to enhance ScreenShare's functionality and reliability. Please follow these guidelines to ensure a smooth collaboration process.
-
Fork the Repository: Create your personal copy of the repository
-
Create a Feature Branch: Use descriptive naming conventions (e.g.,
feature/display-optimization) -
Implement Changes: Follow existing code style and architectural patterns
-
Testing Protocol:
-
Validate changes across multiple platforms
-
Include appropriate unit tests where applicable
-
Document new features and configuration options
-
-
Submit Pull Request: Provide comprehensive description of changes and testing methodology
-
Performance Optimization: Enhanced frame processing or transmission efficiency
-
Platform Compatibility: Extended support for additional operating systems or configurations
-
Feature Enhancements: New functionality aligned with project objectives
-
Documentation Improvements: Enhanced user guides or technical documentation
-
Bug Resolution: Identification and correction of system defects
-
Adhere to PEP 8 style guidelines
-
Include comprehensive docstrings for new functions and classes
-
Maintain backward compatibility for existing functionality
-
Update documentation to reflect interface changes
This project is licensed under the Lesser GNU General Public License (LGPL). See the LICENSE file for details.