-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
[Bug]: Stream gear imposes simplified aspect ratios, which does not seem necessary #385
Comments
@GuillaumeTong Hi, thanks for reporting the issue, and I agree keeping it 10 will cause distortion with large fraction values. I think removing |
- 🏗️ Removed the `-aspect` parameter from the default FFmpeg pipeline - Previously, StreamGear would enforce a simplified aspect ratio using this parameter, which forces FFmpeg to use non-square pixels, leading to unwanted distortion on the output. - 🎨 Updated warning messages for better clarity.
…PI [#401] 💬 This commit includes significant refactoring, documentation updates, and enhancements across StreamGear, WriteGear, and NetGear APIs. It introduces safer process termination methods, improved parameter handling, and enhanced documentation for better user guidance. Additionally, it addresses several bugs and improves the overall maintainability and clarity of the codebase. - Refactored stream copy handling to address errors with unsupported parameters (Fixes #396). - Moved settings for "-vf" and "-aspect" inside conditional blocks. - Added warnings and discarded these parameters in stream copy mode. - Fixed incompatibility of stream copy with Real-time Frames Mode. - Added warnings and discarded `-vcodec copy` when using this mode. - Deprecated `terminate()` method, introducing `close()` for safer process termination. - Updated documentation and tests to reflect these changes. - Introduced new `-enable_force_termination` attribute for immediate FFmpeg process termination. - Restricted `-livestream` parameter to Real-time Frames Mode only. - Disabled live streaming for video files and updated relevant logging. - Removed non-essential aspect ratio parameter to prevent unwanted distortions (Fixes #385). - Enhanced warning messages and clarified documentation. - Updated `close()` methods for handling gracefully signal interruptions on different systems with device audio streams. - Adjusted signals for graceful termination based on the operating system. #### WriteGear API: - Simplified the logic for formatting output parameters. #### NetGear API: - 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. - Enhanced logging and error handling for secure mode. - Logged Authenticator start/stop events. - Handled socket session expiration more gracefully in `recv_handler`. - Fixed `msg_json` undefined when terminating context in the `recv_handler` method. - Ensured proper termination of the ZMQ context and socket when closing the NetGear instance. - Added Admonition for warning users about the Client's end must run before the Server's end to establish a secure connection in Secure Mode. #### Helper Class: - Added a custom deprecated decorator to mark deprecated functions and parameters. - It displays a warning message when a deprecated function or parameter is used. - Updated `extract_time` helper function regex to handle milliseconds. #### Setup - Updated setup.py to use the latest `pyzmq` version to address installation issues (Fixes #399). #### Documentation: - StreamGear Updates: - 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. - 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 the use of new `-enable_force_termination` parameter. - Added a new FAQ entry about the deprecated `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. - Updated the documentation for the `-disable_force_termination` parameter in WriteGear API. - Improved overall documentation quality, including enhancing clarity, readability, consistency, and precision. - Added detailed explanations, practical examples, best practices, and clearer usage patterns. - Fixed various issues like typos, formatting errors, code highlighting issues, and grammar inconsistencies. - Updated sections, code examples, admonitions, and comments for better clarity and accuracy. - Fixed minor typo in `js_hook.py`. #### CI - Improved parameterized test cases to support floating point values. - Fixed various typos and code issues in tests. - 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. - 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. #### Maintenance: - Applied short-circuiting to simplify code across various APIs and tests. - Improved logging, parameter validation, and added descriptive dialogs across various APIs.
This issue is fixed in commit d4243ab |
@GuillaumeTong Now, Streamgear API do not imposes |
Description
When providing frames of unconventional aspect ratios, StreamGear enforces a simplified aspect ratio, Which forces ffmpeg to use non-square pixels, and distorts the output video.
Issue Checklist
Expected behaviour
I expect StreamGear to faithfully stream my frames in any resolution they may come in, without distorting them.
Actual behaviour
As in title and description, my stream is getting distorted, while my application requires outputs to be perfectly aligned.
Steps to reproduce
You may reproduce a distorted steam and its reference image featuring a checkerboard pattern using the script in the "Python Code" section. The input 19:20 aspect ratio gets "rounded" to 9:10, which forces a non-square pixel ratio of
SAR 18:19
.It may be difficult to see the 5% image skew on the resulting video alone with the naked eye, but you can try to align the output image on top of the video to see the width and height cannot both be matched.
Here is "checkerboard.png" and a snapshot of "checkerboard.m3u8" for reference (they mismatch in height):
Terminal log output
Python Code(Optional)
VidGear Version
0.3.2
Python version
Python 3.9.18
OpenCV version
4.8.1
Operating System version
Microsoft Windows 10 Home, Version 10.0.19045 Build 19045
Any other Relevant Information?
I am fairly certain the issue is with these lines (in the current master branch):
vidgear/vidgear/gears/streamgear.py
Lines 427 to 430 in be6f3f0
Specifically,
.limit_denominator(10)
. Is that strictly necessary? I wonder if one of these fixed could be applied:.limit_denominator(10)
altogetherThe text was updated successfully, but these errors were encountered: