jnohlgard / python-v4l2capture

Python extension to capture video with video4linux2 (fork of https://launchpad.net/python-v4l2-capture)
133 stars 83 forks source link

Termination of Python when not able to find video device #13

Open ebaumer opened 9 years ago

ebaumer commented 9 years ago

Dear Gerbart,

Thank you for the awesome python wrapper for v4l2!!!

I running into an issue when v4l2capture can not find a device at the specified path. I have a try/catch statement surrounding the opening of the video device in case the user specifies an incorrect path:

import v4l2capture as vc
try:
    self.cam = vc.Video_device(self.cnfg['devLoc'])       
except:
    ...

As one might expect, for an incorrect path an IOError is returned:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/dev/video5/'

However, unexpectedly, python is immediately terminated as well, whether it be a program or python interactive shell. Is there a way to handle this such that the python shell or program is not immediately terminated?

Thanks!!

jnohlgard commented 9 years ago

Sorry, I have no time to work on this project for now. I have not seen the problem you describe, but I have not tried to use it like that either. Is the Python interpreter killed with a segfault or is it a normal exit?

I would also like to clarify that I did not originally create this library, I only added it to my GitHub because I wanted to make some changes to the upstream code which has been abandoned for some time: https://launchpad.net/python-v4l2-capture The project was originally written by Fredrik Portström (I do not know him, only know his name from the homepage)

jcoffland commented 5 years ago

@ebaumer I don't know if you are still interested in this but I've created a pull request which fixes this problem.