Skip to content

Commit

Permalink
⚡️ VidGear Core: Virtually isolated API specific dependencies [#243]
Browse files Browse the repository at this point in the history
- ⚡️ New behavior to virtually isolate optional API specific dependencies by silencing `ImportError` on all VidGear's APIs import.
- 🎨 Implemented algorithm to cache all imports on startup but silence any `ImportError` on missing optional dependency.
- ⚠️ Now `ImportError` will be raised only when certain API specific dependency is missing during given API's initialization.
- ✨ New `import_dependency_safe` to imports specified dependency safely with `importlib` module.
- ⚡️Replaced all APIs imports with `import_dependency_safe`.
- ⚡️ Added support for relative imports in `import_dependency_safe`.
- ✨ Implemented `error` parameter to by default `ImportError` with a meaningful message if a dependency is missing, Otherwise if `error = log` a warning will be logged and on `error = silent` everything will be quit. But If a dependency is present, but older than specified, an error is raised if specified.
- ✨ Implemented behavior that if a dependency is present, but older than `min_version` specified, an error is raised always.
- ✨ Implemented `custom_message` to display custom message on error instead of default one.
- 🔥 Removed redundant `logger_handler`, `mkdir_safe`, `retrieve_best_interpolation`, `capPropId` helper functions from asyncio package.
- 🎨 Relatively imported helper functions from non-asyncio package.
- ⚡️ Implemented separate `import_core_dependency` function to import and check for specified core dependency. `ImportError` will be raised immediately if core dependency not found.

- WebGear_RTC: 
  - 🐛 Fixed Assertion error bug 
    - 🚑️ Source must raise MediaStreamError when stream ends instead of returning None-type.
    - 👷 Updated CI tests.
    - 📝 Updated Docs Examples.

- Helper:
  - ⚰️ Removed unused `aiohttp` dependency.
  - 🔊 Removed `asctime` from logging.

- 🎨 CamGear: Enforced logging for YouTube live.

- Setup.py:
  - 🔥 Removed version check on certain dependencies.
  - ⏪️ Re-added `aiortc` to auto-install latest version.
  - ➖ Removed all redundant dependencies like `colorama`, `aiofiles`, `aiohttp`.
  - ➕ Added new `cython` and `msgpack` dependency.
  - 🎨 Added `msgpack` and `msgpack_numpy` to auto-install latest.

- CI: 
  - 👷 Imported correct `logger_handler` for asyncio tests.
  - 🐛 Fixed invalid import bug.
  - 🐛 CI: Fixed bug in PiGear tests. 
  - 🐛 Fixed `fake_picamera` class logger calling `vidgear` imports prematurely before importing `picamera` class in tests.
  - 🚑️ Implemented new `fake_picamera` class logger inherently with `logging` module.
  - 🎨 Moved `sys.module` logic for faking to `init.py`.
  - ☂️ Added `__init__.py` to ignore in Codecov.

- Docs:
  - 🗃️ Updated changelog.md and fixed clutter.
  - 📝 Updated URL and context for CamGear example.
  - ✏️ Fixed typos in usage examples.
  - 💡 Updated code comments.
  - ⏪️ Reverted UI change in CSS.
  - 💄 New assets and typos fixed.
  - 🚸 Added `pip` upgrade related docs
  - 📝 Added docs for installing vidgear with only selective dependencies
  - 💄 Added new `advance`/`experiment` admonition with new background color.
  - 🍱 Added new icons svg for `advance` and `warning` admonition.
  - ⚰️ Removed redundant data table tweaks from `custom.css`.
  - 🎨 Beautify `custom.css`.
  - ✏️ Fixed typos in URL links.
  - 🚸 Added bonus examples to help section. 
    - 🚸 Implemented a curated list of more advanced examples with unusual configuration for each API.
    - 💄 Updated admonitions colors and beautified `custom.css`.
    - ⚡️ Replaced VideoGear & CamGear with OpenCV in CPU intensive examples.
    - 📝 Updated `mkdocs.yml` with new changes and URLs.
    - 🚚 Moved FAQ examples to bonus.
    - 📝 Added several new contents and updated context.
    - ✏️ Fixed typos and updated links.
  - 🚸 Added Gitter sidecard embed widget. 
    - 🍱 Imported gitter-sidecar script to `main.html`.
    - 💄 Updated `custom.js` to set global window option.
    - 💄 Updated Sidecard UI in `custom.css`.
    - ⚰️ Removed dead code from docs.
    - ✏️ Fixed more typos.
  • Loading branch information
abhiTronix authored Sep 2, 2021
2 parents c73428d + 7bd77cb commit 0fcc61d
Show file tree
Hide file tree
Showing 80 changed files with 3,897 additions and 1,185 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ In addition to this, WriteGear also provides flexible access to [**OpenCV's Vide

* **Compression Mode:** In this mode, WriteGear utilizes powerful [**FFmpeg**][ffmpeg] inbuilt encoders to encode lossless multimedia files. This mode provides us the ability to exploit almost any parameter available within FFmpeg, effortlessly and flexibly, and while doing that it robustly handles all errors/warnings quietly. **You can find more about this mode [here ➶][cm-writegear-doc]**

* **Non-Compression Mode:** In this mode, WriteGear utilizes basic [**OpenCV's inbuilt VideoWriter API**][opencv-vw] tools. This mode also supports all parameters manipulation available within VideoWriter API, but it lacks the ability to manipulate encoding parameters and other important features like video compression, audio encoding, etc. **You can learn about this mode [here ➶][ncm-writegear-doc]**
* **Non-Compression Mode:** In this mode, WriteGear utilizes basic [**OpenCV's inbuilt VideoWriter API**][opencv-vw] tools. This mode also supports all parameter transformations available within OpenCV's VideoWriter API, but it lacks the ability to manipulate encoding parameters and other important features like video compression, audio encoding, etc. **You can learn about this mode [here ➶][ncm-writegear-doc]**

### WriteGear API Guide:

Expand Down Expand Up @@ -449,10 +449,9 @@ SteamGear also creates a Manifest file _(such as MPD in-case of DASH)_ or a Mast

**StreamGear primarily works in two Independent Modes for transcoding which serves different purposes:**

* **Single-Source Mode:** In this mode, StreamGear transcodes entire video/audio file _(as opposed to frames by frame)_ into a sequence of multiple smaller chunks/segments for streaming. This mode works exceptionally well, when you're transcoding lossless long-duration videos(with audio) for streaming and required no extra efforts or interruptions. But on the downside, the provided source cannot be changed or manipulated before sending onto FFmpeg Pipeline for processing. ***Learn more about this mode [here ➶][ss-mode-doc]***

* **Real-time Frames Mode:** In this mode, StreamGear directly transcodes video-frames _(as opposed to a entire file)_ into a sequence of multiple smaller chunks/segments for streaming. In this mode, StreamGear supports real-time [`numpy.ndarray`](https://numpy.org/doc/1.18/reference/generated/numpy.ndarray.html#numpy-ndarray) frames, and process them over FFmpeg pipeline. But on the downside, audio has to added manually _(as separate source)_ for streams. ***Learn more about this mode [here ➶][rtf-mode-doc]***
* **Single-Source Mode:** In this mode, StreamGear **transcodes entire video file** _(as opposed to frame-by-frame)_ into a sequence of multiple smaller chunks/segments for streaming. This mode works exceptionally well when you're transcoding long-duration lossless videos(with audio) for streaming that required no interruptions. But on the downside, the provided source cannot be flexibly manipulated or transformed before sending onto FFmpeg Pipeline for processing. ***Learn more about this mode [here ➶][ss-mode-doc]***

* **Real-time Frames Mode:** In this mode, StreamGear directly **transcodes frame-by-frame** _(as opposed to a entire video file)_, into a sequence of multiple smaller chunks/segments for streaming. This mode works exceptionally well when you desire to flexibility manipulate or transform [`numpy.ndarray`](https://numpy.org/doc/1.18/reference/generated/numpy.ndarray.html#numpy-ndarray) frames in real-time before sending them onto FFmpeg Pipeline for processing. But on the downside, audio has to added manually _(as separate source)_ for streams. ***Learn more about this mode [here ➶][rtf-mode-doc]***

### StreamGear API Guide:

Expand Down Expand Up @@ -507,7 +506,7 @@ WebGear API works on [**Starlette**](https://www.starlette.io/)'s ASGI applicati

WebGear API uses an intraframe-only compression scheme under the hood where the sequence of video-frames are first encoded as JPEG-DIB (JPEG with Device-Independent Bit compression) and then streamed over HTTP using Starlette's Multipart [Streaming Response](https://www.starlette.io/responses/#streamingresponse) and a [Uvicorn](https://www.uvicorn.org/#quickstart) ASGI Server. This method imposes lower processing and memory requirements, but the quality is not the best, since JPEG compression is not very efficient for motion video.

In layman's terms, WebGear acts as a powerful **Video Broadcaster** that transmits live video-frames to any web-browser in the network. Additionally, WebGear API also provides a special internal wrapper around [VideoGear](#videogear), which itself provides internal access to both [CamGear](#camgear) and [PiGear](#pigear) APIs, thereby granting it exclusive power of broadcasting frames from any incoming stream. It also allows us to define our custom Server as source to manipulate frames easily before sending them across the network(see this [doc][webgear-cs] example).
In layman's terms, WebGear acts as a powerful **Video Broadcaster** that transmits live video-frames to any web-browser in the network. Additionally, WebGear API also provides a special internal wrapper around [VideoGear](#videogear), which itself provides internal access to both [CamGear](#camgear) and [PiGear](#pigear) APIs, thereby granting it exclusive power of broadcasting frames from any incoming stream. It also allows us to define our custom Server as source to transform frames easily before sending them across the network(see this [doc][webgear-cs] example).

**Below is a snapshot of a WebGear Video Server in action on Chrome browser:**

Expand Down Expand Up @@ -558,7 +557,7 @@ web.shutdown()
WebGear_RTC is implemented with the help of [**aiortc**][aiortc] library which is built on top of asynchronous I/O framework for Web Real-Time Communication (WebRTC) and Object Real-Time Communication (ORTC) and supports many features like SDP generation/parsing, Interactive Connectivity Establishment with half-trickle and mDNS support, DTLS key and certificate generation, DTLS handshake, etc.

WebGear_RTC can handle [multiple consumers][webgear_rtc-mc] seamlessly and provides native support for ICE _(Interactive Connectivity Establishment)_ protocol, STUN _(Session Traversal Utilities for NAT)_, and TURN _(Traversal Using Relays around NAT)_ servers that help us to easily establish direct media connection with the remote peers for uninterrupted data flow. It also allows us to define our custom Server as a source to manipulate frames easily before sending them across the network(see this [doc][webgear_rtc-cs] example).
WebGear_RTC can handle [multiple consumers][webgear_rtc-mc] seamlessly and provides native support for ICE _(Interactive Connectivity Establishment)_ protocol, STUN _(Session Traversal Utilities for NAT)_, and TURN _(Traversal Using Relays around NAT)_ servers that help us to easily establish direct media connection with the remote peers for uninterrupted data flow. It also allows us to define our custom Server as a source to transform frames easily before sending them across the network(see this [doc][webgear_rtc-cs] example).

WebGear_RTC API works in conjunction with [**Starlette**][starlette]'s ASGI application and provides easy access to its complete framework. WebGear_RTC can also flexibly interact with Starlette's ecosystem of shared middleware, mountable applications, [Response classes](https://www.starlette.io/responses/), [Routing tables](https://www.starlette.io/routing/), [Static Files](https://www.starlette.io/staticfiles/), [Templating engine(with Jinja2)](https://www.starlette.io/templates/), etc.

Expand Down Expand Up @@ -615,7 +614,7 @@ web.shutdown()
NetGear_Async is built on [`zmq.asyncio`][asyncio-zmq], and powered by a high-performance asyncio event loop called [**`uvloop`**][uvloop] to achieve unmatchable high-speed and lag-free video streaming over the network with minimal resource constraints. NetGear_Async can transfer thousands of frames in just a few seconds without causing any significant load on your system.

NetGear_Async provides complete server-client handling and options to use variable protocols/patterns similar to [NetGear API](#netgear). Furthermore, NetGear_Async allows us to define our custom Server as source to manipulate frames easily before sending them across the network(see this [doc][netgear_Async-cs] example).
NetGear_Async provides complete server-client handling and options to use variable protocols/patterns similar to [NetGear API](#netgear). Furthermore, NetGear_Async allows us to define our custom Server as source to transform frames easily before sending them across the network(see this [doc][netgear_Async-cs] example).

NetGear_Async now supports additional [**bidirectional data transmission**][btm_netgear_async] between receiver(client) and sender(server) while transferring video-frames. Users can easily build complex applications such as like [Real-Time Video Chat][rtvc] in just few lines of code.

Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ ignore:
- "vidgear/tests"
- "docs"
- "scripts"
- "vidgear/gears/__init__.py" #trivial
- "vidgear/gears/asyncio/__main__.py" #trivial
- "setup.py"
4 changes: 4 additions & 0 deletions docs/bonus/reference/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ limitations under the License.

 

::: vidgear.gears.helper.import_dependency_safe

 

::: vidgear.gears.helper.get_video_bitrate

 
Expand Down
8 changes: 0 additions & 8 deletions docs/bonus/reference/helper_async.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ limitations under the License.
===============================================
-->

::: vidgear.gears.asyncio.helper.logger_handler

 

::: vidgear.gears.asyncio.helper.mkdir_safe

 

::: vidgear.gears.asyncio.helper.reducer

 
Expand Down
Loading

0 comments on commit 0fcc61d

Please sign in to comment.