Skip to main content

Powerful Multi-Threaded OpenCV and FFmpeg based Turbo Video Processing Python Library with unique State-of-the-Art Features.

Project description

vidgear Logo

 

PyPi version Build Status Build status Say Thanks

VidGear is a Python library for Turbo Multi-Threaded Video Processing

  • VidGear provides a high-level All-in-One Video Processing framework build on top of OpenCV, PiCamera and FFmpeg. It's compact, simple to use and easy to extend.

  • It contains following Powerful Gears (Multi-Threaded Video Processing classes) to handle/control different device-specific video streams and writer:

    Gear Function
    CamGear Targets any IP-Camera/USB-Camera/Network-Stream/YouTube-Video
    PiGear Targets any Raspberry Pi Camera Modules
    VideoGear Common Gear to access any of the video capture gear
    WriteGear enables Lossless Video Writer with flexible Video Compression capabilities
  • It comes with various in-built features like Flexible Control over Video Source properties like resolution, framerate, colorspace, etc. manipulation and supports easy direct Network stream pipelining (support for GStreamer, YouTube and other network streams like http(s), rtp, rstp, mms, etc.).

  • This library is also very well compatible with the Raspberry-Pi Camera modules (RPiCam) and provides us the ability to exploit its various features like brightness, saturation, sensor_mode, etc. easily.

  • Furthermore, VidGear utilizes FFmpeg's powerful encoders to encode and reduce the output to a smaller size, without sacrificing the video quality. It provide us full-control over FFmpeg output parameters.

 

Key Features

What makes VidGear stand out from other Video Processing tools?

  • Multi-Threaded high-speed Frame capturing (High FPS)
  • Flexible & Direct control over Video Source properties
  • Lossless Video Encoding and Writing
  • Flexible Output Video Encoder, Compression & Quality Control
  • Direct YouTube Video pipelining using its URL address
  • Easy Video Source ColorSpace Conversion
  • Automated prerequisites installation
  • Built-in robust Error and Frame Synchronization handling
  • Multi-Devices Compatibility (including RpiCamera)
  • Support for Live Network Video Streams (including Gstreamer Raw Pipeline)

 

Documentation and Usage

You can checkout VidGear WIKI-SECTION for in-depth documentation with examples for each class

Basic example:

A bare minimum VidGear example to write a Video file in WriteGearclass-Compression Mode(i.e using powerful FFmpeg encoders) with real-time frames captured from a common WebCamera stream by VideoGear video-capture class is as follows:

from vidgear.gears import VideoGear
from vidgear.gears import WriteGear
import cv2

stream = VideoGear(source=0).start() #Open live webcam video stream on first index(i.e. 0) USB device

writer = WriteGear(output_filename = 'Output.mp4') #Define writer with output filename 'Output.mp4'

# infinite loop
while True:

	frame = stream.read()
	# read frames

	# check if frame is None
	if frame is None:
		#if True break the infinite loop
		break

	# do something with frame here

	# write frame to writer
        writer.write(frame) 

        # Show output window
	cv2.imshow("Output Frame", frame)

	key = cv2.waitKey(1) & 0xFF
	# check for 'q' key-press
	if key == ord("q"):
		#if 'q' key-pressed break out
		break

cv2.destroyAllWindows()
# close output window

stream.stop()
# safely close video stream
writer.close()
# safely close writer

 

Prerequisites

Note: Vidgear automatically handles all(except FFmpeg) prerequisites installation required according to your system specifications

Critical:

  • OpenCV(with contrib): VidGear must require OpenCV(3.0+) python enabled library to be installed on your machine which is critical for its core algorithm functioning. You can build it from scratch (for Raspberry Pi), otherwise, Vidgear automatically installs latest OpenCV with contrib python library for you based on your system requirements.

  • FFmpeg: VidGear must requires FFmpeg installation for Compression capabilities. Follow this WIKI Page for latest FFmpeg installation. :warning:

Additional:

  • PiCamera: If you are using Raspberry Pi Camera Modules such as OmniVision OV5647 Camera Module and Sony IMX219 Camera Module. Vidgear requires additional Picamera library installation on your Raspberry Pi machine.

    Also, make sure to enable Raspberry Pi hardware specific settings prior using this library.

  • pafy: For direct YouTube Video Pipelining, Vidgear additionally requires Pafy python library. Additionally for pafy's backend, youtube-dl latest release is required.

 

Installation

  • PyPI: VidGear stable only releases can be easily installed as follows(available on Python Package Index (PyPI)):

    $ pip install vidgear
    
  • Release Tab: All latest Alpha(experimental- may contains bugs) & Stable VidGear release build wheels can be downloaded from Release Tab and thereby installed as follows:

    $ pip install vidgear-0.x.x-py2.py3-none-any.whl
    

 

Development and Testing

  • Clone & Install: You can clone this repository for latest patches (maybe experimental) or development & testing purposes, and thereby can install as follows:

    $ git clone https://github.com/abhiTronix/vidgear.git
    $ cd vidgear
    $ pip install .
    
  • Prerequisites: Testing VidGear require some additional python libraries which can be installed manually as follows:

    $ pip install six
    $ pip install backports.lzma # required by python 2.7 only
    $ pip install pytest
    
  • Download Test-Data: Vidgear also requires test data to test its algorithms which can be downloaded by running this bash script as follows:

    $ chmod +x scripts/pre_install.sh
    $ ./scripts/pre_install.sh # use `sh scripts/pre_install.sh` on windows
    
  • Then various VidGear tests can be run using pytest as follows (in root VidGear folder):

    $ pytest -sv #-sv for verbose output.
    

 

Supported Python versions

  • Python 2.7 is the only supported version in 2.x series. Python 2.7 support will be dropped in the end of 2019.

  • Python 3.x releases follow OpenCV releases.

 

Say Thanks!

If you like this project, say thanks!

Author

Abhishek Thakur @abhiTronix

Contribution and License

You are welcome to contribute with suggestions, feature requests and pull requests.

Copyright © 2019 AbhiTronix

This project is under the MIT License. See the LICENSE file for the full license text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vidgear-0.1.4.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

vidgear-0.1.4-py2.py3-none-any.whl (24.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file vidgear-0.1.4.tar.gz.

File metadata

  • Download URL: vidgear-0.1.4.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for vidgear-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e63fb0376703745fc0e02aed271b50d1a1e413a84697050c04667c1a8dc4da6c
MD5 f9791ff1be162ddd8cb52c29ba78157e
BLAKE2b-256 6d542e192574fa6f1821e183ed266d9645cf37e9fc573419859f17e43b1be099

See more details on using hashes here.

File details

Details for the file vidgear-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: vidgear-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for vidgear-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 601d5e0cb2679adafb2da958450af49149c99303772fc7c1b19ccff14be31470
MD5 c0f31ef1041f77af3b5ff6901b8f1650
BLAKE2b-256 1c2cf5bdbacc75156c5290cbaa0120ed9165f47aac5bd635bf2af40146f57fc4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page