Video Streamer
A Python class for streaming video from a camera or a video file. It supports frame resizing, FPS control, and automatic restart of the video stream in case of errors.
Features
- Stream video from a given source (camera or video file).
- Control the FPS of the video stream.
- Option to resize the video frames.
- Automatic restart of the video stream if the source becomes unavailable.
- Multi-threaded streaming for asynchronous video frame retrieval.
Installation
To install the required dependencies, you need to install OpenCV:
pip install opencv-python
Usage
Here is an example of how to use the VideoStreamer class:
from video_streamer import VideoStreamer
import cv2
# Set your video source (camera index 0 or a video file path)
video_source = "1.avi" # Change this to your video source (0 for webcam, or a video file path)
# Create a VideoStreamer instance
streamer = VideoStreamer(video_source)
# Start the video stream in a separate thread
streamer.start()
# Continuously display the video stream
while True:
frame = streamer.get_frame()
if frame is None:
continue
cv2.imshow("Video Stream", frame)
# Press 'q' to quit the video stream
if cv2.waitKey(300) & 0xFF == ord('q'):
break
# Stop the video stream
streamer.stop_thread()
cv2.destroyAllWindows()
Arguments:
video_source: The source of the video, which could be a file path or a camera index (0for webcam).fps(optional): Frames per second for the video stream. If not provided, the default FPS of the video source is used (or30if unavailable).resolution(optional): A tuple specifying the width and height for resizing the video frames. If not provided, the original resolution of the video source is used.auto_restart(optional): If set toTrue, the video stream will automatically restart if the video source becomes unavailable. Default isFalse.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for monkez-video-input 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| monkez_video_input-0.1.1.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| monkez_video_input-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.2 kB
Release files / monkez_video_input-0.1.1.tar.gz
| Download URL | monkez_video_input-0.1.1.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14aeb9b078351a5e49bdbe323b6bd33f67da6986f742dae103fd616f7bd50573
|
|
BLAKE2b-256 checksum How to use checksums |
9a425cd4b438677547c5eaed47057710b032d02c423029acd4e28e650ede4370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / monkez_video_input-0.1.1-py3-none-any.whl
| Download URL | monkez_video_input-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
985999caf9fc4c47d805fe300a0c0396b67db92e919a534e7477dafd04e872d0
|
|
BLAKE2b-256 checksum How to use checksums |
e345043089287ce1b1ae4c237672ea10ee45c7862b63df091ae7b26ed6ec7785
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|