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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

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