-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Stream resize error #244
Comments
Thanks for opening this issue, a maintainer will get back to you shortly! In the meantime:
|
@ioangatop Yes bug is reproducible. But bug is with OpenCV's GSTREAMER backend and not vidgear. You can test this by:
# clone the repository and get inside
git clone https://github.com/abhiTronix/vidgear.git
vidgear/vidgear/gears/camgear.py Line 136 in eb19b9c
# install normally
cd vidgear
pip install .
from vidgear.gears.helper import dimensions_to_resolutions
from vidgear.gears import VideoGear
import pafy
import cv2
source = "https://youtu.be/j1GLs_fMn1s"
video = pafy.new(source)
valid_streams = dimensions_to_resolutions(
[stream.resolution for stream in video.allstreams]
) # ['144p', '240p', '360p', '480p', '720p', '1080p']
options = {
"STREAM_RESOLUTION": valid_streams[1], # '240p'
"STREAM_PARAMS": {"nocheckcertificate": True},
}
stream = VideoGear(
source=source, stream_mode=True, backend=cv2.CAP_FFMPEG, **options
).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imwrite("frame.jpg", frame)
break
stream.stop() |
@ioangatop Can you confirm your OpenCV version by excuting this command: python3 -c "import cv2; print(cv2.__version__)" |
@abhiTronix thanks for the quick response. My OpenCV version is I guess there isn't an easier way to change / choose the backend, right? |
@ioangatop Thanks, I'm looking into OpenCV issues for clue.
I can make that simpler, but there's a bug with FFmpeg, which made me to enforce Gstreamer backend in the first place. |
@ioangatop OpenCV is crappy in doing VideoIO even with backends. I'm thinking to switch FFmpeg decoding completely with issue #148. But unfortunately, It will going to happen next year due to busy 2021. I think the best resolution to this problem for now is to use |
I'm closing this issue for now. I'll look into it in later versions. |
@abhiTronix thanks! I believe that I'm not sure but I hope that in general, only these resolutions have problems, and its not for this specific stream (meaning if I put another stream |
@ioangatop I'm thinking this is to do with GStreamer opencv/opencv#19025 (comment). As we can see errors in logs: [ WARN:0] global /home/abhishek/Downloads/opencv-master/modules/videoio/src/cap_gstreamer.cpp (898) open OpenCV | GStreamer warning: unable to query duration of stream
[ WARN:0] global /home/abhishek/Downloads/opencv-master/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=450, duration=-1
|
@ioangatop These errors/anomalies are only for Youtube livestreams and not general videos. General videos will works out of the box for any resolution. |
@ioangatop I think #274 resolves this issue too. # install normally
pip install -U vidgear[core] Test your code: from vidgear.gears.helper import dimensions_to_resolutions
from vidgear.gears import VideoGear
import pafy
import cv2
source = "https://youtu.be/j1GLs_fMn1s"
options = {
"STREAM_RESOLUTION": "240p",
"STREAM_PARAMS": {"nocheckcertificate": True},
}
stream = VideoGear(
source=source, stream_mode=True, logging=True, **options
).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imwrite("frame.jpg", frame)
break
stream.stop() |
Successfully resolved and merged in commit: dc26c00 Usage docs are available at: https://abhitronix.github.io/vidgear/latest/gears/camgear/usage/#using-camgear-with-youtube-videos |
Hi! There is an issue with frame fetching from a youtube video when using different resolutions.
Code to reproduce:
Fetched image w/
240p
resolution (happens with480p
as well):Fetched image w/
144p
resolution:Logs
The text was updated successfully, but these errors were encountered: