Closed GuillaumeTong closed 5 months ago
@GuillaumeTong Hi, thanks for reporting the issue, and I agree keeping it 10 will cause distortion with large fraction values. I think removing 10
from limit_denominator
will default to max_denominator=1000000
as mentioned in docs: https://docs.python.org/3/library/fractions.html#fractions.Fraction.limit_denominator which will take care of any ratios.
This issue is fixed in commit https://github.com/abhiTronix/vidgear/commit/d4243ab164ed00020ba66c825a7b920ebd5c44ca
@GuillaumeTong Now, Streamgear API do not imposes -aspect
parameter in its FFmpeg pipeline by default. Goodluck!
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): https://github.com/abhiTronix/vidgear/blob/be6f3f017a85fb589e7d18826d529db2ae3c3176/vidgear/gears/streamgear.py#L427-L430
Specifically,
.limit_denominator(10)
. Is that strictly necessary? I wonder if one of these fixed could be applied:.limit_denominator(10)
altogether