简体   繁体   中英

How to check the default linked codec used by openCV-Python?

I just came into the world of openCV and python, and I'm having a strange issue with opening the video stream. This is the code that I'm using:

import numpy
import cv2

cap = cv2.VideoCapture('SampleVideo.mp4')
print(cap.isOpened())
while(cap.isOpened()):
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

This code can successfully open the video stream when i run it in terminal(windows command line) but not in Pycharm. This is the result of the run in Pycharm:

False

Process finished with exit code 0

Any help would be appreciated. Thank you all!

Codec: FFmpeg. OS: Windows 8.1. Python: 3.5.2. OpenCV: 3.1

Update Sep.27:

I noticed that the code runs successfully in IDLE, but not in PyCharm. Now I'm really confused.

I can also confirm that imread and imwrite works properly in PyCharm. So maybe it is the Codec that is not working? How to check my codec in OpenCV?

Update Sep.29:

Now I think I've ruled out the possibility that the terminal and PyCharm are using different interpreter. I really think it's somehow that the default codec is not linked in the PyCharm environment. How do I check my default system codec either in OpenCV or Python?

The problem is solved.

I solved it by purging everything, Pycharm, Python and all the packages. So obviously this issue came from some sort of dependency mess-up. Not really sure what it is, but purging is the way to go people.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM