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

Pulling Youtube Video #14

Closed
leehanchung opened this issue May 21, 2019 · 11 comments
Closed

Pulling Youtube Video #14

leehanchung opened this issue May 21, 2019 · 11 comments
Assignees
Labels
EXTERNAL BUG 👾 Bug caused by external dependent library SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Milestone

Comments

@leehanchung
Copy link

leehanchung commented May 21, 2019

Copy and pasted your code from :github. The code fail to work. Seems like its returning some None frames similar to feeding cv2 w/ links generated using Pafy.

CODE:

import cv2

stream = CamGear(source='https://youtu.be/dQw4w9WgXcQ', y_tube =True,  time_delay=1, logging=True).start() # YouTube Video URL as input

# infinite loop
while True:

    frame = stream.read()
    # read frames

    # check if frame is None
    if frame is None:
        #if True break the infinite loop
        break

    # do something with frame here

    cv2.imshow("Output Frame", frame)
    # Show output window

    key = cv2.waitKey(1) & 0xFF
    # check for 'q' key-press
    if key == ord("q"):
        #if 'q' key-pressed break out
        break

cv2.destroyAllWindows()
# close output window

stream.stop()
# safely close video stream.

OUTPUT:

python vidgear_test.py 
Title: Rick Astley - Never Gonna Give You Up (Video)
Extension: webm

pipenv config:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
numpy = "*"
opencv-python = "*"
jupyter = "*"
tensorflow = "*"
pillow = "*"
matplotlib = "*"
youtube-dl = "*"
pafy = "*"
vidgear = "*"

[requires]
python_version = "3.6"
@abhiTronix

This comment has been minimized.

@abhiTronix abhiTronix added BUG 🐛 Vidgear api's error, flaw or fault WAITING TO TEST ⏲️ Asked user to test the suggested example/binary/solution EXEMPLARY 🎖️ Exemplary for newcomers labels May 21, 2019
@leehanchung

This comment has been minimized.

@abhiTronix

This comment has been minimized.

@abhiTronix abhiTronix removed the WAITING TO TEST ⏲️ Asked user to test the suggested example/binary/solution label May 21, 2019
@abhiTronix abhiTronix self-assigned this May 21, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented May 21, 2019

@leehanchung Bug discovered in opencv-contrib-python or opencv-python python libraries !

Bug summary:

opencv-contrib-python python library's VideoCapture class fails to parse URL received from pafy directly. But strangely this bug doesn't exist on a machine with OpenCV installed from scratch.

Affected users:

Users with OpenCV installed with opencv-contrib-python or opencv-python python library from PyPi

Non-Affected users:

Users with OpenCV installed from scratch/source-code and not from PyPi

Test-Code:

import cv2
import pafy

video = pafy.new("dQw4w9WgXcQ")
object = video.getbestvideo()
url = object.url
print(url) #means pafy and youtube-dl working correctly

stream = cv2.VideoCapture(url)

# infinite loop
while True:
	(grabbed, frame) = stream.read()
	# read frames

	# check if frame empty
	if not grabbed:
		print('opencv is buggy')
		break

	cv2.imshow("Output Frame", frame)
	# Show output window

	key = cv2.waitKey(1) & 0xFF
	# check for 'q' key-press
	if key == ord("q"):
		#if 'q' key-pressed break out
		break

cv2.destroyAllWindows()
# close output window

stream.release()
# safely close video stream.

Temporary Workaround: 💡

Uninstall opencv-contrib-python python library and install OpenCV from Scratch

@abhiTronix
Copy link
Owner

Update:

I've addressed this bug on opencv-python repo. here.

@abhiTronix abhiTronix added this to the v0.1.5 milestone May 23, 2019
@leehanchung
Copy link
Author

Confirmed. Building opencv from scratch under Ubuntu 18.04 worked.

@abhiTronix abhiTronix added EXTERNAL BUG 👾 Bug caused by external dependent library BUG CONFIRMED ✅ Bug is confirmed! and removed BUG 🐛 Vidgear api's error, flaw or fault EXEMPLARY 🎖️ Exemplary for newcomers labels May 28, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented Jun 6, 2019

Update:

Travis CLI Tests for VidGear will now use Travis OpenCV Binaries prebuilt from scratch, starting from commit 3b75132

@abhiTronix abhiTronix modified the milestones: v0.1.5, v0.1.6 Jul 19, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented Jul 19, 2019

Update:

Due to delay from opencv-python repository author in fixing this issue, the milestone has been shifted to next v0.1.6 release.

@abhiTronix abhiTronix added WORK IN PROGRESS 🚧 currently been worked on. and removed BUG CONFIRMED ✅ Bug is confirmed! labels Jul 31, 2019
@abhiTronix
Copy link
Owner

Update:

I've pushed a PR: opencv/opencv-python#229 to finally fix this bug.

@abhiTronix
Copy link
Owner

abhiTronix commented Aug 18, 2019

Update:

Successfully Resolved in commit opencv/opencv-python@eed0f0d . Binaries will be available soon. Then this issue will be closed.

TODO

  • Update Docs.

@abhiTronix abhiTronix added SOLVED 🏁 This issue/PR is resolved now. Goal Achieved! and removed WORK IN PROGRESS 🚧 currently been worked on. labels Aug 18, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented Sep 3, 2019

@leehanchung Binary Released on Pypi with this bug fixed: https://pypi.org/project/opencv-python/4.1.1.26/

Install it with:

sudo pip install -U python-opencv

Goodluck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EXTERNAL BUG 👾 Bug caused by external dependent library SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Projects
None yet
Development

No branches or pull requests

2 participants