This project provides a simple setup to stream video using HLS (HTTP Live Streaming) and a lightweight Flask web server. It captures video using libcamera-vid, processes it with ffmpeg, and serves the stream over a local network through a Flask-based interface.
- Live Video Capture: Streams live video using
libcamera-vid. - HLS Streaming: Processes the video stream into HLS format for playback in browsers.
- Flask Web Server: Serves the HLS video stream with a simple HTML5 video player.
- Responsive Cleanup: Ensures processes are terminated gracefully when the script stops.
- Raspberry Pi or similar device with camera support.
libcamera-vidffmpeg- Python 3.x
- Flask
hls.jsfor video playback
-
Clone the repository:
git clone https://github.com/mattmascolo/security-camera.git cd /security-camera.git -
Install Python dependencies:
pip install flask
-
Ensure
libcamera-vidandffmpegare installed:sudo apt install libcamera-apps ffmpeg
-
Run the script:
./start_stream.sh
-
Access the video stream in your browser:
- Navigate to
http://<your-device-ip>:5000in a browser on the same network.
- Navigate to
start_stream.sh: Main script to initialize the video stream and Flask server.stream_server.py: Flask application for serving the HLS video stream.static/hls/: Directory where HLS video files are stored.
- The video stream is served on port
5000by default. Ensure this port is open on your device. - This setup is intended for local network use. For external access, additional security measures should be implemented.
- The
debug=Truemode in Flask is enabled for development. Disable it in production for security.
-
Video stream not loading:
- Ensure the camera is connected and properly configured.
- Check that
libcamera-vidandffmpegare installed and working.
-
Cannot access the stream in the browser:
- Confirm the IP address of your device and that it's reachable from the client device.