
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
A Flask-based web streaming solution for Raspberry Pi cameras using PiCamera2
A Flask-based web streaming solution for Raspberry Pi cameras using PiCamera2. Stream your Raspberry Pi camera feed securely over HTTPS with minimal latency.
A split installation approach ensures compatibility with Raspberry Pi OS while keeping application-specific dependencies isolated.
pip install picamera2-webstream
For a quick automated installation:
git clone https://github.com/glassontin/picamera2-webstream.git
cd picamera2-webstream
For an ffmpeg based webstream:
./install_ffmpeg.sh
For a picamera2 OpenCV based webstream use:
./install_picamera.sh
The installation script will:
After installation completes:
source venv/bin/activate
python examples/ffmpeg_stream.py
https://your-pi-ip
in your browserTo uninstall:
./uninstall.sh
Two streaming implementations are available:
from picamera2_webstream import FFmpegStream, create_ffmpeg_app
stream = FFmpegStream(
width=1280,
height=720,
framerate=30,
device='/dev/video0'
).start()
app = create_ffmpeg_app(stream)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=443, ssl_context=('cert.pem', 'key.pem'))
Advantages:
from picamera2_webstream import VideoStream, create_picamera_app
stream = VideoStream(
resolution=(1280, 720),
framerate=30,
brightness=0.0,
contrast=1.0
).start()
app = create_picamera_app(stream)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=443, ssl_context=('cert.pem', 'key.pem'))
Advantages:
Use FFmpeg-based streaming when:
Use PiCamera2-based streaming when:
For either implementation:
https://your-pi-ip
To find the optimal settings for your camera, run the diagnostic tool:
python examples/camera_diagnostics.py
This will:
You can customize various parameters when initializing the VideoStream:
stream = VideoStream(
resolution=(1280, 720), # Width x Height
framerate=30, # Target framerate
format="MJPEG", # Video format
brightness=0.0, # -1.0 to 1.0
contrast=1.0, # 0.0 to 2.0
saturation=1.0 # 0.0 to 2.0
)
Common camera settings:
To see all available settings for your camera:
# List all video devices
v4l2-ctl --list-devices
# Show device capabilities (replace X with your device number)
v4l2-ctl -d /dev/videoX --all
# List supported formats
v4l2-ctl -d /dev/videoX --list-formats-ext
For USB cameras, you might also want to check:
# Show detailed USB device information
lsusb -v | grep -A 10 "Video"
If you want to modify the code:
# Clone and enter the repository
git clone https://github.com/glassontin/picamera2-webstream.git
cd picamera2-webstream
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in editable mode
pip install -e .
pip install pytest
pytest
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
PiCamera2 Web Streamer now includes intelligent camera detection that ensures it always finds the correct camera device, even if Linux changes the /dev numbering:
examples/find_camera.py
to troubleshoot camera detectionIn config.ini
, you can configure camera detection:
[camera]
# Override auto-detection with a specific camera index
# camera_index = 0
# Force detection by USB vendor:product ID
usb_camera_id = 0c45:636d
The new version includes a robust logging system:
Logs are stored in /var/log/picamera2-webstream.log
and rotated weekly.
Common issues and solutions:
Camera not detected:
raspi-config
libcamera-hello
commandpython examples/find_camera.py
Camera found but with incorrect device:
usb_camera_id = vendor:product
python examples/find_camera.py
Excessive logging:
level = WARNING
Environment=LIBCAMERA_LOG_LEVELS=*:WARNING
sudo logrotate /etc/logrotate.d/picamera2-webstream
ImportError for picamera2:
sudo apt install python3-libcamera python3-picamera2
Permission denied errors:
sudo usermod -a -G video $USER
FAQs
A Flask-based web streaming solution for Raspberry Pi cameras using PiCamera2
We found that picamera2-webstream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.