You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: https URL not working with opencv-python #204
opencv-contrib-python python library's VideoCapture class fails to parse https URL received from pafy/youtube-dl. But strangely this bug doesn't exist on same/different machine with OpenCV installed from scratch.
You can copy url directly to cv2.VideoCapture class and this result in same Bug.
importcv2importpafyvideo=pafy.new("dQw4w9WgXcQ")
object=video.getbestvideo()
url=object.urlprint(url) #means pafy and youtube-dl working correctlystream=cv2.VideoCapture(url)
# infinite loopwhileTrue:
(grabbed, frame) =stream.read()
# read frames# check if frame emptyifnotgrabbed:
print('opencv is buggy')
breakcv2.imshow("Output Frame", frame)
# Show output windowkey=cv2.waitKey(1) &0xFF# check for 'q' key-pressifkey==ord("q"):
#if 'q' key-pressed break outbreakcv2.destroyAllWindows()
# close output windowstream.release()
# safely close video stream.
This code exit instantly with no error on opencv-python 4.1.0.25 since no frame grabbed BUT instead this algorithm works when OpenCV installed from scratch and returns valid frames.
@abhiTronixcv2 installed using pip install opencv-python fail to load any http videos but works when I installed it from scratch. The .getBuildInformation() printout of my working cv2 installation has no GStreamer.
The issue is not GStreamer but FFmpeg. It's most likely compiled without https support or some other build flag is missing and therefore it cannot open Youtube video streams.
@skvark Thanks for this valuable info. Problem is indeed with FFmpeg, and I've discovered the solution:
It's most likely compiled without https support or some other build flag is missing and therefore it cannot open Youtube video streams.
Yes, FFmpeg is compiled with no support for openssl that enables support for https and other protocols in FFmpeg, missing in docker file you provided. It can solved with following steps:
Install libssl development files: debian: sudo apt install libssl-dev, or on redhat: yum install -y openssl-devel
Add --enable-openssl --enable-nonfree --enable-protocol= file,ftp,http,https,httpproxy,hls,mmsh,mmst,pipe,rtmp,rtmps,rtmpt,rtmpts,rtp,sctp,srtp,tcp,udp flags to the FFmpeg configure.
Thanks. Note that the flag --enable-nonfree cannot be added because the resulting build must licensed under LGPL (--enable-nonfree makes it GPL). I think OpenSSL has a permissive license, but it must be checked that GPL'ed components are not included.
Note that the flag --enable-nonfree cannot be added because the resulting build must licensed under LGPL (--enable-nonfree makes it GPL). I think OpenSSL has a permissive license, but it must be checked that GPL'ed components are not included.
Why GPL License is not good? Please test if FFmpeg works with openSSL without --enable-nonfree flag.
Also when will be these changes will be integrated into opencv-python binaries, are you working on a new PR or You need my help on this?
If there are GPL'ed components I would have to re-license the whole package under GPL license and any package using opencv-python, respectively, would have to be licensed under GPL. This would also mean that this package or any package which uses opencv-python could not be used for commercial purposes / proprietary applications.
I have to re-buid the Docker images and check if this problem is present also on macOS. I cannot give any timetable when this will happen. Please note that this is not a bug. This is a feature request. If you wish to speed up the process, you can try to enable the SSL support in FFmpeg builds locally in the Docker images, build a opencv-python wheel and test if the solution works.
If there are GPL'ed components I would have to re-license the whole package under GPL license and any package using opencv-python, respectively, would have to be licensed under GPL. This would also mean that this package or any package which uses opencv-python could not be used for commercial purposes / proprietary applications.
I have to re-buid the Docker images and check if this problem is present also on macOS. I cannot give any timetable when this will happen. Please note that this is not a bug. This is a feature request. If you wish to speed up the process, you can try to enable the SSL support in FFmpeg builds locally in the Docker images, build a opencv-python wheel and test if the solution works.
Thank you for this valuable information. I don't want this feature just right now, but my vidgear python library relies on opencv-python for its core functions and for features like Live YouTube streaming, Thereby I just need heads up from your end to plan next update for vidgear accordingly. So I'll wait for this change and also, I've linked this issue to parent issue on vidgear. Again thanks for letting me know.
To the best of our knowledge, [Fraunhofer FDK AAC and OpenSSL] are compatible with the LGPL.
git blame'ing configure shows that openssl has been marked nonfree since its adoption and there are no explanation of the reason.
I believe this may have been done to discourage users from choosing these "problematic" libraries over freer alternatives -- in particular, to remove any technical roadblocks to using GPLed parts.
Also, How do I test these changes, as I currently have access to a Ubuntu machine only? and What should I keep in my mind while making this PR, any special instructions?
The other Dockerfile, too.
You'll need to mimic the build logic as close as practical. IIRC running setup.py bdist_wheel in the resulting container and checking cv2.getBuildInformation() of the resulting wheel (and your use case, naturally) should be enough to check the SSL support specifically.
If you enable Travis CI for your fork, you can override the link to Docker image that's somewhere in the build scripts and run the official build logic with your image.
The libjpeg-turbo can be removed from the Dockerfiles. It has been there since beginning and I haven't had the time remove it. FYI: I can't provide much support during next 5-7 days but I will try to answer if there's something urgent.
Activity
abhiTronix commentedon May 22, 2019
leehanchung commentedon May 23, 2019
@abhiTronix
cv2installed usingpip install opencv-pythonfail to load any http videos but works when I installed it from scratch. The.getBuildInformation()printout of my workingcv2installation has no GStreamer.skvark commentedon May 24, 2019
The issue is not GStreamer but FFmpeg. It's most likely compiled without https support or some other build flag is missing and therefore it cannot open Youtube video streams.
Your script works under Windows which confirms that this is related to FFmpeg build time configuration. To see the FFmpeg build flags check out the Dockerfiles: https://github.com/skvark/opencv-python/blob/master/docker/Dockerfile_x86_64
abhiTronix commentedon May 24, 2019
@skvark Thanks for this valuable info. Problem is indeed with FFmpeg, and I've discovered the solution:
Yes, FFmpeg is compiled with no support for openssl that enables support for
httpsand other protocols in FFmpeg, missing in docker file you provided. It can solved with following steps:Install libssl development files: debian: sudo apt install libssl-dev, or on redhat: yum install -y openssl-devel
Add
--enable-openssl --enable-nonfree --enable-protocol= file,ftp,http,https,httpproxy,hls,mmsh,mmst,pipe,rtmp,rtmps,rtmpt,rtmpts,rtp,sctp,srtp,tcp,udpflags to the FFmpeg configure.Please take a look here:
https://askubuntu.com/questions/650577/how-to-compile-ffmpeg-with-https-support
https://stackoverflow.com/questions/43565190/couldnt-open-https-stream-protocol-not-found-ffmpeg-with-openssl
skvark commentedon May 24, 2019
Thanks. Note that the flag
--enable-nonfreecannot be added because the resulting build must licensed under LGPL (--enable-nonfreemakes it GPL). I think OpenSSL has a permissive license, but it must be checked that GPL'ed components are not included.abhiTronix commentedon May 24, 2019
Thanks, @skvark for the update,
Why GPL License is not good? Please test if FFmpeg works with openSSL without
--enable-nonfree flag.Also when will be these changes will be integrated into opencv-python binaries, are you working on a new PR or You need my help on this?
skvark commentedon May 24, 2019
If there are GPL'ed components I would have to re-license the whole package under GPL license and any package using opencv-python, respectively, would have to be licensed under GPL. This would also mean that this package or any package which uses opencv-python could not be used for commercial purposes / proprietary applications.
I have to re-buid the Docker images and check if this problem is present also on macOS. I cannot give any timetable when this will happen. Please note that this is not a bug. This is a feature request. If you wish to speed up the process, you can try to enable the SSL support in FFmpeg builds locally in the Docker images, build a opencv-python wheel and test if the solution works.
abhiTronix commentedon May 24, 2019
Thank you for this valuable information. I don't want this feature just right now, but my
vidgearpython library relies onopencv-pythonfor its core functions and for features like Live YouTube streaming, Thereby I just need heads up from your end to plan next update forvidgearaccordingly. So I'll wait for this change and also, I've linked this issue to parent issue onvidgear. Again thanks for letting me know.abhiTronix commentedon May 25, 2019
@skvark Hey, Take a look at this issue: opencv/opencv#14617, Is this related?
mshabunin commentedon May 27, 2019
@abhiTronix , it is not related, that issue is caused by very long string incorrectly processed by built-in CAP_IMAGES backend.
native-api commentedon Jun 23, 2019
Actually, the complete opposite:
However, despite
opensslmarked nonfree inconfigurelogic, https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md#incompatible-libraries claims:git blame'ingconfigureshows thatopensslhas been marked nonfree since its adoption and there are no explanation of the reason.I believe this may have been done to discourage users from choosing these "problematic" libraries over freer alternatives -- in particular, to remove any technical roadblocks to using GPLed parts.
Whatever is the case, GNU TLS (LGPL) should work as an alternative.
native-api commentedon Jul 30, 2019
@abhiTronix since you are the interested party, could you make a PR?
abhiTronix commentedon Jul 30, 2019
@native-api Yeah sure, Please correct me if I'm wrong, I've to make changes to this line:
https://github.com/skvark/opencv-python/blob/da7d02271d2ffca8f293ed3f3032f30881319db8/docker/Dockerfile_x86_64#L53
Also, How do I test these changes, as I currently have access to a Ubuntu machine only? and What should I keep in my mind while making this PR, any special instructions?
native-api commentedon Jul 30, 2019
The other Dockerfile, too.
You'll need to mimic the build logic as close as practical. IIRC running
setup.py bdist_wheelin the resulting container and checkingcv2.getBuildInformation()of the resulting wheel (and your use case, naturally) should be enough to check the SSL support specifically.If you enable Travis CI for your fork, you can override the link to Docker image that's somewhere in the build scripts and run the official build logic with your image.
abhiTronix commentedon Jul 30, 2019
Thanks, will do.
Also @native-api and @skvark , Why the
libjpeg-turbolibs are being built from scratch in the docker file here:https://github.com/skvark/opencv-python/blob/da7d02271d2ffca8f293ed3f3032f30881319db8/docker/Dockerfile_x86_64#L63
When OpenCV itself provide optimized
libjpeg-turbolibs starting from this PR: opencv/opencv#11497 ?Added OpenSSL & different protocol support to FFmpeg backend
skvark commentedon Jul 30, 2019
The libjpeg-turbo can be removed from the Dockerfiles. It has been there since beginning and I haven't had the time remove it. FYI: I can't provide much support during next 5-7 days but I will try to answer if there's something urgent.
abhiTronix commentedon Jul 30, 2019
@skvark it seemed to add latency to the already lengthy CLI builds, that's a bit concerning. Anyways thanks for the clarification. Should I remove it?
Also, I've pushed the PR #229 to fix this issue finally.
Added OpenSSL & various protocol support to FFmpeg backend (#229)
abhiTronix commentedon Aug 20, 2019
Successfully Fixed & Merged in #229
Added OpenSSL & various protocol support to FFmpeg backend (#229)