Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸŽ‰ Release VidGear Stable v0.3.3 #411

Merged
merged 86 commits into from
Jun 22, 2024
Merged

πŸŽ‰ Release VidGear Stable v0.3.3 #411

merged 86 commits into from
Jun 22, 2024

Conversation

abhiTronix
Copy link
Owner

Brief Description

This pull request introduces Vidgear version 0.3.3, which includes a significant update featuring new functionalities, improvements, and crucial bug fixes across various components of the library.

Key PR Changes:

New Features ✨

  • PiGear:
    • Official Support for Picamera2 API (Fixes [Proposal]: Support Picamera2Β #342)
      • This massive update brings official support for the new Picamera2 API, unlocking powerful features for Raspberry Pi Camera Modules and limited USB camera support.
      • Seamless Python wrapper: A robust wrapper around Picamera2 API library simplifies integration with minimal code changes for existing PiGear users.
      • Enhanced camera control: Leverages libcamera API under the hood for Raspberry Pi Camera Modules.
      • Existing compatibility: Maintains compatibility with PiGear's existing super-charged multi-threaded and colorspace manipulation framework.
      • Proper Resource management: Ensures proper resource release during PiGear termination.
      • USB camera support (limited): Provides basic functionality for USB webcams. PiGear could accurately differentiates between USB and Raspberry Pi cameras using metadata.
      • Backward compatibility: Seamlessly switches to the legacy Picamera library backend if Picamera2 is unavailable.
      • Standalone functionalities: Standalone functionalities for both legacy picamera and newer picamera2 backends for clarity.
      • Advanced optional parameters handling: Handles camera configurational parameters and user-defined settings for various camera types.
        • New optional configurational parameters: Currently Supports "sensor", "format", "controls", "transform", "stride", "buffer_count", and "queue" with sanity checks. Seperated Raspberry Pi camera module exclusive and Unified USB cameras supported optional parameters.
        • New user-defined optional parameters: Such as auto_align_output_config, enable_verbose_logs, and more.
  • StreamGear:
    • Introduced new -enable_force_termination attribute for immediate FFmpeg process termination.
  • Helper:
    • Added a custom deprecated decorator to mark deprecated functions and parameters.
      • It displays a warning message when a deprecated function or parameter is used.
  • Docs:
    • Overhauled mkdocs theme.
      • Added unrecognized_links: ignore to mkdocs.yml for validations.
      • Added custom admonition icons to mkdocs.yml
      • Added new git-authors plugin in mkdocs.yml
      • Added new tables markdown extension in mkdocs.yml
      • Added custom fences to pymdownx.superfences markdown extension.
      • Added line_spans: __span and pygments_lang_class: true parameters to pymdownx.highlight markdown extension.
      • Added normalize_issue_symbols: true to pymdownx.magiclink markdown extension.
      • Added new mkdocs feature dependency mkdocs-git-authors-plugin.
    • Added the use of new -enable_force_termination parameter.
    • Added a new FAQ entry about the deprecated rgb_mode parameter.
    • Added new screengear_error11.png asset.
  • CI:
    • Added test cases for import_dependency_safe function to validate different scenarios and error handling in import_dependency_safe.

Updates/Improvements ⚑️

  • Core:
    • Improved exception handling for module imports.
      • Updated import_dependency_safe in helper.py:
        • Added specific handling for ModuleNotFoundError.
        • Included original exception in ImportError for better error tracing.
        • Enhanced logging to include exception traceback when error is set to "log".
      • Enhanced import_core_dependency in __init__.py:
        • Added specific handling for ModuleNotFoundError.
        • Included original exception in ImportError for better error tracing.
    • Improved colorspace handling in videocapture gears
      • Logged a warning and discarded invalid colorspace values instead of raising an exception.
      • Consolidated colorspace logging into a single line using a ternary operation.
  • Asyncio:
  • NetGear_Async API:
    • Modified __init__ method to handle event loop more robustly:
      • Try to get the running event loop using asyncio.get_running_loop()
      • If no running event loop found, create a new one with asyncio.new_event_loop()
      • Log if creating a new event loop
    • Changed launch method to use self.loop.create_task() instead of asyncio.ensure_future()
      • Ensures the task is created using the correct event loop instance.
    • Moved the event loop initialization code to an earlier point before setting event loop policy to ensure it is set up correctly before selecting WindowsSelectorEventLoop policy.
      • On Windows, vidgear requires the WindowsSelectorEventLoop, but Python 3.8 and above defaults to the ProactorEventLoop which is not compatible.
    • Removed redundant python version check to set WindowsSelectorEventLoop policy, as minimum supported version is already 3.8.
    • Move event loop setup and policy assignment to the beginning of __init__ before zmq Context creation.
    • Refactored return data handling.
  • StreamGear:
    • Updated close() methods for handling gracefully signal interruptions based on different operating systems with device audio streams.
    • Deprecated terminate() method, introducing close() for safer process termination.
    • Enhanced stream copy support in Single Source mode (Fixes [Proposal]: -vcodec copy HLSΒ #396).
      • Moved settings for "-vf" and "-aspect" inside conditional blocks.
      • Added warnings and discarded these parameters in stream copy mode.
      • Ignored stream copy parameter in Real-time Frames Mode or Custom Streams with appropriate warnings.
      • Updated -acodec handling:
        • Default to aac for Custom Streams.
        • Use stream copy (-acodec copy) for input video’s audio when Custom Streams are disabled.
      • Refined -livestream parameter usage to Real-time Frames Mode only.
      • Adjusted video and audio bitrate assignment to skip when stream copy is enabled.
      • Improved log message for -clear_prev_assets parameter.
    • Restricted -livestream parameter to Real-time Frames Mode only.
      • Disabled live streaming for video files and updated relevant logging.
    • Enhanced warning messages and clarified description.
  • PiGear:
    • Logging optimization with warning for common libcamera messages.
    • Lowered framerate minimum value to 0.0.
    • Moved sensor optional parameter to commonly supported picamera2 configurational parameters.
    • Removed unsupported bit_depth optional parameters.
    • Updated PiGear API tagline and introduction.
  • NetGear:
    • Enhanced logging and error handling for secure mode.
    • Logged Authenticator start/stop events.
    • Handled socket session expiration more gracefully in recv_handler.
    • Ensured proper termination of the ZMQ context and socket when closing the NetGear instance.
  • WebGear:
  • WebGear_RTC:
    • Optimized peer connection closure to avoid redundant closures.
    • Reduced unnecessary logging by only logging ICE connection state changes when they are not in a "failed" state.
  • WriteGear:
    • Simplified the logic for formatting output parameters.
    • Improved error handling in execute_ffmpeg_cmd method:
      • Raised ValueError with descriptive messages for BrokenPipeError or IOError.
      • Updated error handling per PEP 409 to preserve original exception context or suppress it based on logging settings.
  • CamGear:
    • Removed GStreamer support check.
    • Improved readability of livestream warning logs.
  • Setup.py:
  • Helper:
    • Added patch for substring index bug in get_supported_demuxers helper method.
    • Updated extract_time helper function regex to handle milliseconds.
  • Docs:
    • Update StreamGear documentation:
      • Updated documentation to deprecated terminate() method, and introducing close() for safer process termination.
      • Improved the overview section's description and wording.
      • Updated usage examples for both Single-Source Mode and Real-time Frames Mode.
      • Updated StreamGear usage examples for device audio input.
      • Refactored sections for Live Streaming usage.
        • Added warning for unsupported -livestream parameter in Single-Source Mode.
      • Added a tip box on benefits of using stream copy (-vcodec copy) for faster HLS/DASH transcoding.
        • Highlighted limitations of stream copy, including incompatibility with Real-time Frames Mode and Custom Streams.
        • Clarified automatic audio stream copy (-acodec copy) usage with input video’s audio stream.
      • Updated usage example for device video source.
      • Addressed deprecation of the terminate() method in favor of the new close() method.
      • Updated respective notices for the deprecated terminate() method and rgb_mode parameter.
      • Added a deprecation warning admonition for the rgb_mode parameter in the stream() method.
      • Removed the obsolete usage example for deprecation RGB mode with StreamGear.
      • Added documentation and usage of the new -enable_force_termination parameter.
      • Modified the warning message to mention that forced termination can cause corrupted output in certain scenarios.
      • Updated the docstring for the stream() method and transcode_source() method.
      • Refactored the StreamGear API Parameters documentation to enhance clarity and readability.
      • Refined the description of the -streams attribute of the StreamGear API.
    • Update PiGear documentation:
      • Added a warning advising users to disable common libcamera messages when logging is disabled.
      • Updated Picamera2 installation instructions (including apt, pip, pre-installation on Raspberry Pi images, and compatibility warnings)
      • Moved legacy Picamera library installation instructions to an admonition.
      • Removed Importing section from overview to avoid confusion.
    • Update NetGear documentation:
    • Update WriteGear documentationL
      • Updated the documentation for the -disable_force_termination parameter.
    • Update README.md:
      • Replaced deprecated options (frame_jpeg_quality, frame_jpeg_optimize, frame_jpeg_progressive) with their newer equivalents (jpeg_compression_quality, jpeg_compression_fastdct, jpeg_compression_fastupsample) in WebGear usage example.
    • Update mkdocs.yml:
      • Set edit_uri for GitHub edit links
      • Add new theme features like content actions, tooltips, etc.
      • Update palette settings for light/dark mode
      • Enable new markdown extensions
      • Add custom javascript hook support.
      • Migrated to new Google Analytics 4 in mkdocs.yml
      • Replaced depreciated materialx with supported emoji extension.
      • Replaced permalink icon with default one.
    • Improved overall documentation quality, including enhancing clarity, readability, consistency, and precision.
    • Added detailed explanations, practical examples, best practices, and clearer usage patterns.
    • Updated sections, code examples, admonitions, and comments for better clarity and accuracy.
    • Added missing version contributors to changelog.md
    • Added new icons to make headings more readable
    • Replaced unsupported admonitions with supported ones
    • Removed all custom admonition icons and color CSS from custom.css
    • Removed Twitter section from help and docs site metadata
    • Updated Zenodo badge and BibTeX entry
    • Added workaround for 'AttributeError: 'DXCamera' object has no attribute 'is_capturing'' error on Windows.
    • Remove script tags from main.html and use a custom hook for adding javascripts on certain pages.
    • Refactored all APIs and bonus examples to use linenums and hl_lines which makes it easier to highlight specific lines in code blocks.
    • Removed Gitter community chat sidecard JS file.
    • Redefined spacing between sections.
    • Change system mode toggle icon and name in mkdocs.yml.
    • Add failure warning in various docs about picamera incompatibility on 64-bit OS.
    • Update announcement icon in main.html.
    • Remove site.webmanifest file.
  • Maintenance:
    • Applied short-circuiting to simplify code across various APIs and tests.
    • Improved logging, parameter validation, and added descriptive dialogs across various APIs.
    • Moved logging enablement before version logging for consistency in vidgear APIs.
    • Removed redundant boolean assignment for various APIs internal logging.
    • Simplified conditional statements and assignments using short-circuiting, Boolean operations, and ternary operators.
    • Refactored vidgear code to improve readability, maintainability, and performance,
    • Added .cache directory to .gitignore,
    • Updated vidgear library version to v0.3.3.
    • Improved code efficiency with short-circuiting and formatting.
    • Updated logging practices to be more developer-friendly.
    • Updated code highlighting.
    • Corrected a typo in comments.
    • Simplified code using short-circuiting.
    • Removed unnecessary parentheses and type checks.
    • Removed unused imports.
    • Updated code comments.
  • CI:
    • Temporarily removed PiGear API from code coverage due to hardware limitations.
    • Deprecated custom event_loop fixture overrides in WebGear_RTC and NetGear_Async tests
      • Removed redundant pytest.mark.asyncio decorators from several test functions.
    • Add a new event_loop_policy fixture for pytest to override the event loop policy:
      • Added new recommended approach of using pytest.mark.asyncio(scope="module") to mark all WebGear_RTC and NetGear_Async tests as asynchronous and utilize the same event loop throughout the module.
      • Log the event loop being used for debugging.
    • Updated NetGear unit tests to reflect the new default for copy.
    • Ensured coverage for raise, log, silent, and unknown error types.
    • Improved parameterized test cases to support floating point values.
    • Updated StreamGear tests to use the new close() method instead of the deprecated terminate() method.
    • Updated tests of various APIs for better coverage and reliability.
    • Enabled kill=True in close() in NetGear Tests.
    • Removed pinned cryptography==38.0.4 dependency.
    • Remove unused imports and code cleanup.
    • Rearranged the dependencies.

Breaking Updates/Changes πŸ’₯

  • StreamGear:
    • Deprecated terminate() method and introduce close() method.
      • The terminate() method in StreamGear is now deprecated and will be removed in a future release. Developers should use the new close() method instead, which provides a more descriptive name like in WriteGear API for terminating StreamGear processes safely.
    • Deprecated rgb_mode parameter in stream() method.
      • This parameter will be removed in a future version, and only BGR format frames will be supported.
    • Restricted -livestream parameter to Real-time Frames Mode only.
      • Live streaming is intended for low-latency streaming of real-time frames, where chunks contain only the most recent frames. It doesn't make sense when streaming from a video file, as the entire file can be streamed normally without the need for live streaming.

Bug-fixes πŸ›

  • PiGear:
    • Modify PiGear class behavior when enforce_legacy_picamera=True on unsupported system
      • Instead of silently disabling picamera2 API directly, PiGear now raises an error if picamera is unavailable or unsupported
      • Prevented incorrect initialization of PiGear class on unsupported 64-bit OS systems.
    • Fixed UnboundLocalError bug for 'picamera2' variable assigment.
    • Fixed UnboundLocalError bug for 'queue' variable assignment.
    • Fixed colorspace typo bug.
  • StreamGear:
  • NetGear:
    • Fixed Secure Mode failing to work on conflicting ZMQ Contexts:
      • Handled "Address in use" error more gracefully and disabled secure mode if errors occur.
      • Improved handling of ZMQ Authenticator and Certificates.
    • Fixed msg_json undefined when terminating context in the recv_handler method.
  • CamGear:
  • Docs:
    • Replaced buggy kofi widget with a button image in index.md.
    • Fixed Ko-fi sponsorship heart hover effect in footer
      • Replaced twemoji heart emoji with heart-pulse fontawesome SVG
    • Fixed titles and indentations in various admonitions.
    • Fixed various code comments, and hyperlinks URLs.
    • Fixed various issues like typos, formatting errors, code highlighting issues, and grammar inconsistencies.
    • Fixed typos, formatting, code highlighting, and grammar issues.
    • Fixed minor typo in js_hook.py.
  • CI:
    • Fixed simplejpeg and opencv not compatible with numpy==2.x.x versions.
      • Pinned numpy<2.0.0 in all CI envs.
    • Fixed expected duration value in parameterized test case from 8 to 8.44 since test_extract_time function now supports floating point values.
    • Fixed test_secure_mode NetGear test:
      • Added "127.0.0.1" address to allow common endpoint for connection.
      • Added "jpeg_compression":False to disable frame compression, allowing frame to be the same while assertion.
    • Fixed pip install hash bug in Azure Pipelines CI.
    • Fixed various typos and code issues in tests.
    • Fixed invalid escape sequence in testcase string.
    • Fixed python environment bugs in appveyor.yml.

Requirements / Checklist

Related Issue

#410
#394
#403
#390
#396
#385
#399
#397
#342

Context

This update significantly enhances Vidgear's capabilities, ensuring better performance, broader compatibility, and improved user experience. The introduction of the Picamera2 API support, enhanced error handling, and detailed documentation updates are pivotal in making Vidgear more robust and user-friendly.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Screenshots (if available):

✨ This update brings official support for the new Picamera2 API, unlocking powerful features for Raspberry Pi Camera Modules and limited USB camera support.

Key improvements:
- 🚸 Seamless Python wrapper: A robust wrapper around Picamera2 API library simplifies integration with minimal code changes for existing PiGear users.
- ⚑️ Enhanced camera control: Leverages libcamera API under the hood for Raspberry Pi Camera Modules.
- ⚑️ Existing compatibility: Maintains compatibility with PiGear's existing super-charged multi-threaded and colorspace manipulation framework.
- ⚑️ Resource management: Ensures proper resource release during PiGear termination.
- ✨ USB camera support (limited): Provides basic functionality for USB webcams. PiGear could accurately differentiates between USB and Raspberry Pi cameras using metadata.
- πŸ§‘β€πŸ’» Backward compatibility: Seamlessly switches to the legacy PiCamera library if Picamera2 is unavailable.
- πŸ§‘β€πŸ’» Standalone functionalities: Separates functionalities for both legacy and newer APIs for clarity.
- ⚑️ Automatic configuration management: Handles common configuration parameters and non-standard settings for various camera types.
- New internal parameters:
  - 🚩 auto_align_output_config: Optimizes output frame configuration for the camera sensor.
  - 🚩 enable_verbose_logs: Enables more detailed logging through Picamera2.
- Unified `format` parameter:
  - πŸ₯… Defaults to RGB888 (24-bit BGR) for Raspberry Pi cameras.
  - 🦺 Validates formats for USB cameras before handling.
  - πŸ₯… Requires explicit `colorspace` definition if `format` is not MPEG (USB cameras) or for specific formats in Raspberry Pi cameras.
- Raspberry Pi camera exclusive parameters:
  - 🚩 Currently Supports `"controls," "queue," "transform," "bit_depth," "buffer_count," "sensor," and "stride"` with type checks.
- ⚑️ Framerate handling: Tailored framerate handling based on camera type.
- 🦺 Logging optimization: Added a warning advising users to disable common libcamera messages when logging is disabled.

Additional Changes:
- πŸ’₯ Dropped legacy `picamera` dependency in `Setup.py`.
- πŸ’‘ Improved code efficiency with short-circuiting and formatting.
- πŸ”Š Updated logging practices.

CI:
- πŸ—οΈ Temporarily removed PiGear API from code coverage due to hardware limitations.
- πŸ§‘β€πŸ’» Replaced legacy Picamera library installation instructions with Picamera2 python library.
- πŸ“ Added two methods of Picamera2 installation: using `apt`(recommended) and using `pip`.
- 🚸 Added information admonition about Picamera2 comes pre-installed on images downloaded from Raspberry Pi.
- 🚸 Added warning admonition Picamera2 is only supported on Raspberry Pi OS Bullseye (or later) images.
- 🚸 Moved legacy Picamera library optional installation instructions to a Admonition.
- πŸ”‡ Added `unrecognized_links: ignore` to mkdocs.yml for validations to minimize logging.
- πŸ“ Updated vidgear library binaries version.
- πŸ“ Added new `navigation.tabs.sticky`, `navigation.tracking`, `navigation.instant`, and `navigation.instant.progress` features.
- πŸ“± Replaced docs font `Muli` with `Source Sans 3`.
- πŸ’„ Added custom admonition icons to `mkdocs.yml`.
- 🚩 Added `enable_creation_date:true` and `fallback_to_build_date: true` to `git-revision-date-localized` plugin.
- 🚚 Migrated to new Google Analytics 4 in mkdocs.yml.
- ✨ Added new `git-authors` plugin in `mkdocs.yml`.
- ✨ Added new `tables` markdown extension.
- 🚩 Added `custom_fences` to `pymdownx.superfences` markdown extension.
- 🚩 Added `line_spans: __span` and `pygments_lang_class: true` parameters to `pymdownx.highlight` markdown extension.
- 🚩 Added `normalize_issue_symbols: true` to `pymdownx.magiclink` markdown extension.
- ✨ Added complete Picamera2 library installation instructions for pip and source.
  - 🚚 Moved legacy picamera python library installation instructions to admonition.
- βž• Added new mkdocs feature dependency `mkdocs-git-authors-plugin`.
- πŸ‘₯ Added missing version contributors to changelog.md
- πŸ§‘β€πŸ’» Added new icons to make headings more readable.
- πŸ—‘οΈ Replace depreciated `materialx` with supported `extensions` emoji extension.
- 🩹 Fixed titles and indentations in various admonitions.
- πŸ“ Replaced permalink icon with default one.
- 🩹 Replaced wrong unsupported admonitions with supported ones.
- πŸ”₯ Removed all custom admonition icons and color CSS from `custom.css`.
- πŸ™ˆ Added `.cache` directory to `.gitignore`.
- πŸ”₯ Removed Twitter section from help and site metadata.
- 🩹 Fixed Ko-fi sponsorship heart hover effect in footer.
- πŸ’„ Replace twemoji `heart` with `heart-pulse` fontawesome SVG.
- πŸ”₯ Removed Gitter community chat sidecard js.
- πŸ’„ Redefined spacing between sections.
- ✏️ Fixed small typos and hyperlinks.
- 🚩 Moved `sensor` optional parameter to common supported picamera2 config parameters.
- πŸ”₯ Removed unsupported `bit_depth`, `buffer_count`, `queue` optional parameter from picamera2 config parameters.
- πŸ₯… Added sanity checks for `sensor` optional parameter, only `output_size`, `bit_depth` config parameters are supported.
- πŸ₯… Added sanity checks for `controls` optional parameter, only camera sensor specific config parameters extracted using `camera.camera_controls` are supported.
- πŸ’‘ Added comments related to `controls`, `transform` and `stride` not supported with USB cameras.
- πŸ”Š Updated logs to be more developer friendly.
- πŸ“ Added a concise tagline of the PiGear API. Emphasize its seamless wrapper around Picamera2, compatibility with various camera modules, and robust resource management through the Threaded Internal Timer feature.
- πŸ§‘β€πŸ’» Update the PiGear API introduction in the documentation to provide a more concise and intuitive summary. Highlight the key features, such as seamless Picamera2 integration, enhanced camera control, USB camera support, and automatic configuration management.
- ♿️ Reflected these updated changes in `README.md` and `index.md`, and PiGear source code comments.
- 🩹 Fixed colorspace typo bug in PiGear API.
- πŸ’‘ Fixed minor code comments.
…ation

- **Overview**
    - πŸ“ Updated the description for the camera module and added limited USB camera support with the `Picamera2` backend.
    - πŸ§‘β€πŸ’»  Added backward compatibility information for seamless legacy `Picamera` switching.
- **Parameters**
    - 🚸 Clarified the `camera_num` parameter to allow multiple cameras.
    - πŸ“ Updated the `options` parameter with new sections:
        - Configurational Camera Parameters (provided by the backend library).
        - User-defined Parameters (e.g., `enforce_legacy_picamera`, `enable_verbose_logs`).
    - πŸ§‘β€πŸ’» Updated admonitions, examples, and text for each parameter.
- **Usage Examples**
    - πŸ“ Updated examples for Picamera2 configuration, user-defined parameters, and legacy Picamera usage.
    - ✨ Added new admonitions on:
        - Picamera2 configurational parameters (with table) and library installation.
        - Enabling verbose logs for the Picamera2 backend.
        - Limited USB camera support with the Picamera2 backend.
        - Prioritization of the Picamera2 backend and enforcing the legacy backend.
        - Disabling common `libcamera` messages in silent mode.
    - πŸ“ Updated the usage example to include examples for both the `picamera2` and legacy `picamera` backends when using the PiGear API.
- **Bonus Examples**
    - ✨ Added examples for changing the output pixel format and accessing multiple cameras (Picamera2 backend).
    - ✨ Added new example for dynamically adjusting Raspberry Pi Camera Parameters at Runtime in the PiGear API for both the `picamera2` and legacy `picamera` backends.
- **FAQ**
    - πŸ“ Updated answers to refer to the "Switching from OpenCV" guide and API documentation.
    - ✨ Added new questions and answers related to PiGear API features.
- πŸ“ Updated the PiGear description to include support for camera modules and limited USB cameras on Raspberry Pis.
- ✨ Added a note about enforcing the legacy Picamera API backend using the `enforce_legacy_picamera` parameter in various documents concerning the PiGear API.
- 🚸Updated formatting and readability in various documentation files.
- πŸ§‘β€πŸ’» Updated the warning message about enabling Raspberry Pi camera hardware-specific settings.
- πŸ’„Added `content.footnote.tooltips` feature in `mkdocs.yml`.

- πŸ—οΈMoved logging enablement before version logging for consistency.
- πŸ”₯Removed redundant boolean assignment for `self.__logging`.
- πŸ§‘β€πŸ’» Simplified conditional statements and assignments using short-circuiting, Boolean operations, and ternary operators.
- ♻️ In `netgear_async.py`: Refactored return data handling in `recv_generator`.
- ♻️ vidgear code has been refactored to improve readability, maintainability, and performance.
- πŸ§‘β€πŸ’» Renamed references from 'PiCamera2' to 'picamera2' for consistency
- 🚩 Added option to enforce legacy picamera API with 'enforce_legacy_picamera' optional boolean parameter.
- ⚑️Improved logging and warning messages for unsupported/custom formats.
- ✨ Added `buffer_count` and `queue` configuration parameter options for picamera2 API.
- πŸ—οΈ Renamed `auto_align_output_config` to `auto_align_output_size`.
- πŸ”Š Included `buffer_count` and `queue` in `picamera2` parameter logging.
- ✏️ Fixed a typo in the error message for Camera Module API failure.
- πŸ’‘ Clarified comments for thread joining during `stop()`.
- 🚸 Minor code formatting and comment updates.
…ted_demuxers` method.

Docs:
- πŸ“ Updated the PiGear API's example to new Picamera2 backend in README.md.
- πŸš€ Applied new Picamera2 backend integration documentation changes to StreamGear, plus VideoGear and its dependent WebGear, WebGear_RTC, and NetGear_Async API's Parameters, Usage and Bonus examples.
- ✏️ Fixed typos typos and context in documentation.
- ✏️ Fixed typos in hyperlink URLs.
πŸš€ This massive update brings official support for the new Picamera2 API, unlocking powerful features for Raspberry Pi Camera Modules and limited USB camera support. 

### ✨Key PiGear Enhancements include:
- **Seamless Python wrapper:** A robust wrapper around Picamera2 API library simplifies integration with minimal code changes for existing PiGear users.
- **Enhanced camera control:** Leverages libcamera API under the hood for Raspberry Pi Camera Modules.
- **Existing compatibility:** Maintains compatibility with PiGear's existing super-charged multi-threaded and colorspace manipulation framework.
- **Proper Resource management:** Ensures proper resource release during PiGear termination.
- **USB camera support (limited):** Provides basic functionality for USB webcams. PiGear could accurately differentiates between USB and Raspberry Pi cameras using metadata.
- **Backward compatibility:** Seamlessly switches to the legacy Picamera library backend if Picamera2 is unavailable.
- **Standalone functionalities:** Standalone functionalities for both legacy `picamera` and newer `picamera2` backends for clarity.
- **Document Overhaul:** * 
- **Advanced optional parameters handling:** Handles camera configurational parameters and user-defined settings for various camera types.
	- **New optional configurationalparameters:** Currently Supports "sensor", "format", "controls", "transform", "stride", "buffer_count", and "queue" with sanity checks. Seperated Raspberry Pi camera module exclusive and Unified USB cameras supported optional parameters.
	- **New user-defined optional parameters:** Such as `auto_align_output_config`, `enable_verbose_logs`, and more.
- **Additional changes:**
	* Logging optimization with warning for common libcamera messages
	* Lowered `framerate` minimum value to `0.0`.
	* Moved `sensor` optional parameter to commonly supported picamera2 configurational parameters.
	* Removed unsupported `bit_depth` optional parameters
	* Updated PiGear API tagline and introduction 
	* Fixed colorspace typo bug
	* Fixed UnboundLocalError bug for 'picamera2' variable assigment.
	* Fixed UnboundLocalError bug for 'queue' variable assignment.

### πŸ“ Documentation updates:
* Added a warning advising users to disable common `libcamera` messages when logging is disabled.
* Updated Zenodo badge and BibTeX entry
* Added complete Picamera2 library installation instructions for `pip` and from source as a dependency. 
* Updated Picamera2 installation instructions _(including `apt`, `pip`, pre-installation on Raspberry Pi images, and compatibility warnings)_
* Moved legacy Picamera library installation instructions to an admonition.
* Removed Importing section from overview to avoid confusion in PiGear.
* Overhauled mkdocs theme.
  * Added `unrecognized_links: ignore` to `mkdocs.yml` for validations.
  * Added new `features` to mkdocs.yml 
	* Added custom admonition icons to mkdocs.yml 
	* Migrated to new Google Analytics 4 in mkdocs.yml 
	* Added new `git-authors` plugin in mkdocs.yml 
	* Added new tables markdown extension 
	* Added custom fences to `pymdownx.superfences` markdown extension 
	* Added `line_spans: __span` and `pygments_lang_class: true` parameters to `pymdownx.highlight` markdown extension 
	* Added `normalize_issue_symbols: true` to `pymdownx.magiclink` markdown extension 
	* Added new mkdocs feature dependency mkdocs-git-authors-plugin
	* Replaced depreciated `materialx `with supported emoji extension.
	* Replaced permalink icon with default one 
* Added missing version contributors to `changelog.md`
* Added new icons to make headings more readable
* Replaced unsupported admonitions with supported ones 
* Removed all custom admonition icons and color CSS from `custom.css`
* Removed Twitter section from help and docs site metadata
* Fixed Ko-fi sponsorship heart hover effect in footer 
	* Replaced `twemoji` heart emoji with `heart-pulse` fontawesome SVG  
* Fixed titles and indentations in various admonitions.
* Removed Gitter community chat sidecard JS file.
* Redefined spacing between sections 
* Fixed various typos, code comments, and hyperlinks URLs. 

### πŸ§‘β€πŸ’» Maintenance Updates:
* Moved logging enablement before version logging for consistency in vidgear APIs.
* Removed redundant boolean assignment for various APIs internal logging.
* Simplified conditional statements and assignments using short-circuiting, Boolean operations, and ternary operators.
* Refactored return data handling in netgear_async.py
* Refactored vidgear code to improve readability, maintainability, and performance
* Added `.cache` directory to `.gitignore` 
* Updated vidgear library version to `v0.3.3`
* Dropped legacy picamera dependency in Setup.py 
* Improved code efficiency with short-circuiting and formatting
* Updated logging practices to be more developer-friendly
* Updated code highlighting in NetGear_Async Docs
* Added patch for substring index bug in `get_supported_demuxers` helper method.
* Updated code comments 

### πŸ‘·CI Updates:
* Temporarily removed PiGear API from code coverage due to hardware limitations 
* Fixed `pip install` hash bug in Azure Pipelines CI.
…edirect

- πŸ’š Change mike deploy commands in `deploy_docs.yml` to use `--alias-type=copy`
  instead of `--no-redirect` for release, stable, and dev deployments
- πŸ’¬ Update `main.html` announcement text with minor wording changes
- ♿️ Set default version in `mkdocs.yml` to 'latest'
…o attribute 'is_capturing'' error on Windows.

- πŸ’„ Added new `screengear_error11.png` asset.
- πŸ—οΈ Replaced deprecated Starlette's `on_shutdown` parameter with an async context manager `lifespan` in WebGear and WebGear_RTC APIs.
- 🚚 Moved shutdown logic for VideoGear and peer RTC connections to this new `lifespan` context manager.
- πŸ“¦οΈ Added new `contextlib` import for using `asynccontextmanager`.

Docs:
- πŸ“ Update README.md with changes to JPEG compression options
  - ✏️ Replaces deprecated options (`frame_jpeg_quality`, `frame_jpeg_optimize`, `frame_jpeg_progressive`) with their newer equivalents (`jpeg_compression_quality,` `jpeg_compression_fastdct`, `jpeg_compression_fastupsample`) in WebGear usage example.
- πŸ‘· Added new recommended approach of using `pytest.mark.asyncio(scope="module")` to mark all WebGear_RTC and NetGear_Async tests as asynchronous and utilize the same event loop throughout the module.
- πŸ—‘οΈ Deprecated custom `event_loop` fixture overrides in WebGear_RTC and NetGear_Async tests.
- πŸ”₯ Removed redundant `pytest.mark.asyncio` decorators from several test functions.
- ⚑️Modified `__init__` method to handle event loop more robustly:
    - Try to get the running event loop using `asyncio.get_running_loop()`
    - If no running event loop found, create a new one with `asyncio.new_event_loop()`
    - Log if creating a new event loop
- πŸ§‘β€πŸ’» Changed launch method to use `self.loop.create_task()` instead of `asyncio.ensure_future()`
    - Ensures the task is created using the correct event loop instance.
- ⚑️ Moved the event loop initialization code to an earlier point before setting event loop policy to ensure it is set up correctly before selecting `WindowsSelectorEventLoop` policy.
  - πŸ’¬ Background: On Windows, vidgear requires the `WindowsSelectorEventLoop`, but Python 3.8 and above defaults to the `ProactorEventLoop` which is not compatible.
- πŸ”₯ Removed redundant python version check to set `WindowsSelectorEventLoop` policy, as minimum supported version is already `3.8`.
- πŸ’‘ Updated code comments.
- πŸ› Replaced buggy kofi widget with a button image in index.md
- πŸ—οΈ Remove script tags from main.html and use a custom hook for adding JS
- πŸ”₯ Remove site.webmanifest file
- πŸ’„ Update mkdocs.yml with new configuration settings:
    - Set edit_uri for GitHub edit links
    - Add new theme features like content actions, tooltips, etc.
    - Update palette settings for light/dark mode
    - Enable new markdown extensions
    - Add custom JS hook for adding scripts on certain pages
- ♻️ Other minor tweaks and cleanups
- πŸ‘· Add a new event_loop_policy fixture for pytest to override the event loop policy
- πŸ”Š Log the event loop being used for debugging
- πŸ”§ Mark the new fixture in relevant test functions with pytest.mark.asyncio(scope="module")
- ♻️ Remove unused imports and code cleanup

NetGear_Async:
- ⚑️ Move event loop setup and policy assignment to the beginning of `__init__` before zmq Context creation.
- πŸ§‘β€πŸ’» Refactored all APIs and bonus examples to use linenums and hl_lines
    - Makes it easier to highlight specific lines in code blocks
- πŸ“ Updated remaining code examples for picamera2 and legacy picamera backends
- πŸ› Replaced buggy kofi widget with a button image in  `help.md`
- πŸ’„ Update announcement icon in `main.html`
- πŸ’„ Change system mode toggle icon and name in `mkdocs.yml`
…ra=True` on unsupported system

- ⚑️ Instead of silently disabling `picamera2` API directly, PiGear now raises an error if `picamera` is unavailable or unsupported
- πŸ₯… Prevented incorrect initialization of `PiGear` class on unsupported 64-bit OS systems.

Docs:
- πŸ“ Add failure warning in various docs about `picamera` incompatibility on 64-bit OS
- πŸ—οΈ Replaced deprecated Starlette's `on_shutdown` parameter with an async context manager `lifespan` in WebGear and WebGear_RTC APIs.
- 🚚 Moved shutdown logic for VideoGear and peer RTC connections to this new `lifespan` context manager.
- πŸ“¦οΈ Added new `contextlib` import for using `asynccontextmanager`.

### NetGear_Async API:
- 🩹 Fixed event loop handling 
    - ⚑️Modified `__init__` method to handle event loop more robustly:
        - Try to get the running event loop using `asyncio.get_running_loop()`
        - If no running event loop found, create a new one with `asyncio.new_event_loop()`
        - Log if creating a new event loop
    - πŸ§‘β€πŸ’» Changed launch method to use `self.loop.create_task()` instead of `asyncio.ensure_future()`
        - Ensures the task is created using the correct event loop instance.
- πŸš‘οΈ  Fix event loop initialization on Windows platforms 
    - ⚑️ Moved the event loop initialization code to an earlier point before setting event loop policy to ensure it is set up correctly before selecting `WindowsSelectorEventLoop` policy.
      - πŸ’¬ Background: On Windows, vidgear requires the `WindowsSelectorEventLoop`, but Python 3.8 and above defaults to the `ProactorEventLoop` which is not compatible.
    - πŸ”₯ Removed redundant python version check to set `WindowsSelectorEventLoop` policy, as minimum supported version is already `3.8`.
    - πŸ’‘ Updated code comments.
- ⚑️ Move event loop setup and policy assignment to the beginning of `__init__` before zmq Context creation.

### PiGear API: 
- πŸš‘οΈ Modify PiGear class behavior when `enforce_legacy_picamera=True` on unsupported system
    - ⚑️ Instead of silently disabling `picamera2` API directly, PiGear now raises an error if `picamera` is unavailable or unsupported
    - πŸ₯… Prevented incorrect initialization of `PiGear` class on unsupported 64-bit OS systems.

### Docs: 
- πŸ“ Added workaround for 'AttributeError: 'DXCamera' object has no attribute 'is_capturing'' error on Windows.
- πŸ’„ Added new `screengear_error11.png` asset.
- πŸ“ Update README.md with changes to JPEG compression options
  - ✏️ Replaces deprecated options (`frame_jpeg_quality`, `frame_jpeg_optimize`, `frame_jpeg_progressive`) with their newer equivalents (`jpeg_compression_quality,` `jpeg_compression_fastdct`, `jpeg_compression_fastupsample`) in WebGear usage example.
- πŸ› Replaced buggy kofi widget with a button image in index.md
- πŸ—οΈ Remove script tags from main.html and use a custom hook for adding JS
- πŸ”₯ Remove site.webmanifest file
- πŸ’„ Update mkdocs.yml with new configuration settings:
    - Set edit_uri for GitHub edit links
    - Add new theme features like content actions, tooltips, etc.
    - Update palette settings for light/dark mode
    - Enable new markdown extensions
    - Add custom JS hook for adding scripts on certain pages
- ♻️ Other minor tweaks and cleanups
- πŸ§‘β€πŸ’» Refactored all APIs and bonus examples to use linenums and hl_lines
    - Makes it easier to highlight specific lines in code blocks
- πŸ“ Updated remaining code examples for picamera2 and legacy picamera backends
- πŸ› Replaced buggy kofi widget with a button image in  `help.md`
- πŸ’„ Update announcement icon in `main.html`
- πŸ’„ Change system mode toggle icon and name in `mkdocs.yml`
- πŸ“ Add failure warning in various docs about `picamera` incompatibility on 64-bit OS

### CI: 
- πŸ’š Deprecated event_loop fixture overrides. 
    - πŸ‘· Added new recommended approach of using `pytest.mark.asyncio(scope="module")` to mark all WebGear_RTC and NetGear_Async tests as asynchronous and utilize the same event loop throughout the module.
    - πŸ—‘οΈ Deprecated custom `event_loop` fixture overrides in WebGear_RTC and NetGear_Async tests.
    - πŸ”₯ Removed redundant `pytest.mark.asyncio` decorators from several test functions.
- πŸ’š Refactor event loop handling 
    - πŸ‘· Add a new event_loop_policy fixture for pytest to override the event loop policy
    - πŸ”Š Log the event loop being used for debugging
    - πŸ”§ Mark the new fixture in relevant test functions with pytest.mark.asyncio(scope="module")
    - ♻️ Remove unused imports and code cleanup
πŸ’¬ When the output codec is set to "copy" (stream copy mode), certain video
processing parameters like "-vf" (video filters) and "-aspect" (aspect ratio)
are not supported and can lead to errors and invalid output files.

♻️ This commit refactors the internal `PreProcess` method in StreamGear API to handle
the stream copy mode correctly:

- πŸ₯… Moved the existing code for setting "-vf" and "-aspect" inside conditional block that checks if
  the output stream codec is not "copy".
- πŸ”Š Added an else block to log warnings and discard "-vf" and "-aspect" in stream copy mode.
- ⚑️ Updated `import_dependency_safe` in `helper.py`:
  - πŸ₯… Added specific handling for `ModuleNotFoundError`.
  - πŸ§‘β€πŸ’» Included original exception in `ImportError` for better error tracing.
  - πŸ”Š Enhanced logging to include exception traceback when error is set to "log".

- ⚑️ Enhanced `import_core_dependency` in `__init__.py`:
  - πŸ₯… Added specific handling for `ModuleNotFoundError`.
  - πŸ§‘β€πŸ’» Included original exception in `ImportError` for better error tracing.
.
- ⚑️ Included various test cases to validate different scenarios and error handling in `import_dependency_safe`.
- β˜” Ensured coverage for `raise`, `log`, `silent`, and unknown error types.
#### WebGear_RTC:
- Optimized peer connection closure to avoid redundant closures.
- Reduced unnecessary logging by only logging ICE connection state changes when they are not in a "failed" state.

#### StreamGear:
- Enhanced stream copy support in Single Source mode (Fixes #396)
  - Ignored stream copy parameter in Real-time Frames Mode or Custom Streams with appropriate warnings.
  - Updated `-acodec` handling:
    - Default to `aac` for Custom Streams.
    - Use stream copy (`-acodec copy`) for input video’s audio when Custom Streams are disabled.
  - Refined `-livestream` parameter usage to Real-time Frames Mode only.
  - Adjusted video and audio bitrate assignment to skip when stream copy is enabled.
  - Improved log message for `-clear_prev_assets` parameter.
- Moved handle streaming format to beginning to fix 'StreamGear' object has no attribute '_StreamGear__format' bug.

#### CamGear:
- Removed GStreamer support check.
- Improved readability of livestream warning logs.

#### WriterGear:
- Improved error handling in `execute_ffmpeg_cmd` method:
  - Raised `ValueError` with descriptive messages for `BrokenPipeError` or `IOError`.
  - Updated error handling per PEP 409 to preserve original exception context or suppress it based on logging settings.

#### NetGear: Updated parameters and documentation (Fixes #390)
- Added warning log for potential issues with `flag=1` (NOBLOCK).
- Noted that `track` option is ignored when `copy=True`.

### Core: 
- Improved exception handling for module imports. 
  - Updated `import_dependency_safe` in `helper.py`:
    - dded specific handling for `ModuleNotFoundError`.
    - Included original exception in `ImportError` for better error tracing.
    - Enhanced logging to include exception traceback when error is set to "log".
  - Enhanced `import_core_dependency` in `__init__.py`:
    - Added specific handling for `ModuleNotFoundError`.
    - Included original exception in `ImportError` for better error tracing.

#### Maintenance:
- Refactored colorspace handling in videocapture gears
  - Logged a warning and discarded invalid colorspace values instead of raising an exception.
  - Consolidated colorspace logging into a single line using a ternary operation.
- Simplified code using short-circuiting.
- Corrected a typo in comments.
- Removed unnecessary parentheses and type checks.
- Removed unused imports.

#### Docs:
- Enhanced StreamGear documentation:
  - Added a tip box on benefits of using stream copy (`-vcodec copy`) for faster HLS/DASH transcoding.
  - Highlighted limitations of stream copy, including incompatibility with Real-time Frames Mode and Custom Streams.
  - Clarified automatic audio stream copy (`-acodec copy`) usage with input video’s audio stream.
- Changed default value of `copy` to `True` in NetGear API documentation.
- Fixed typos, formatting, code highlighting, and grammar issues.

#### CI:
- Enhanced WebGear RTC tests
- Updated NetGear unit tests to reflect the new default for `copy`.
- Fixed simplejpeg and opencv not compatible with `numpy==2.x.x` versions.
  - Pinned `numpy<2.0.0` in all CI envs.
- Added test cases for import_dependency_safe function to validate different scenarios and error handling in `import_dependency_safe`.
  - Ensured coverage for `raise`, `log`, `silent`, and unknown error types.
- Fixed invalid escape sequence in testcase string.
- Fixed python environment bugs in `appveyor.yml`.
- Removed pinned `cryptography==38.0.4` dependency.
- πŸ”Š Updated `no_warnings` parameter in `CamGear` to be `False` when logging is enabled and `True` otherwise.
#403)

- ⚑️ Updated `homepage`, `not_found`, and `server_error` methods to include more detailed JSON error messages.
- πŸ₯… Added specific error and message prefixes to improve clarity.
πŸ“ Docs: Fixed minor code highlighting
#### CamGear: 
- Fixed logging condition for yt-dlp (Fixes #394) 
  - Updated `no_warnings` parameter in `CamGear` to be `False` when logging is enabled and `True` otherwise.

#### WebGear: 
- Enhanced error messages for WebGear auto-generation workflow (Fixes #403)
  - Updated `homepage`, `not_found`, and `server_error` methods to include more detailed JSON error messages.
  - Added specific error and message prefixes to improve clarity.

#### CI: 
- Rearranged the dependencies 

#### Docs: 
- Minor updates to reference page titles.
- Fixed minor code highlighting
… version.

- πŸ“Œ Pinned `simplejpeg>=1.7.3` to support python-3.8 legacies.
 #410)

- ⚑️ Enhanced `is_valid_url` in `helper.py` to recognize and support both `rtsp` and `rtsps` protocols. (Suggested by @jonra1993)
- πŸ’¬ SRTP/RTSPS extends RTSP/RTP to encrypt video and audio data using the same ciphers as HTTPS, typically AES with a 128-bit key length.
@abhiTronix abhiTronix added BUG πŸ› Vidgear api's error, flaw or fault ENHANCEMENT ⚑ New Feature/Addition/Improvement MAINTENANCE πŸ—οΈ Just sorting things out! WORK IN PROGRESS 🚧 currently been worked on. NEW RELEASE πŸ”₯ New Release. Yay! DOCS πŸ“œ Issue/PR is related to vidgear docs. META πŸ’­ Meta Issue/PR labels Jun 22, 2024
@abhiTronix abhiTronix added this to the v0.3.3 milestone Jun 22, 2024
@abhiTronix abhiTronix self-assigned this Jun 22, 2024
@abhiTronix abhiTronix added this to In progress in VidGear v0.3.3 via automation Jun 22, 2024
@abhiTronix abhiTronix merged commit 5f4127b into master Jun 22, 2024
4 checks passed
VidGear v0.3.3 automation moved this from In progress to Done Jun 22, 2024
@abhiTronix abhiTronix deleted the testing branch June 22, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment