
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
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.
Common issues and solutions:
Camera not detected:
raspi-config
libcamera-hello
commandImportError for picamera2:
sudo apt install python3-libcamera python3-picamera2
SSL Certificate issues:
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.