jbaiter / gphoto2-cffi

Python bindings for libgphoto2 with an idiomatic API
GNU Lesser General Public License v3.0
37 stars 16 forks source link

VideoCaptureContext #14

Open hknox opened 8 years ago

hknox commented 8 years ago

Hello. I am trying to control a Nikon D750 from a Python script. I want to be able to start video recording, wait for something to happen elsewhere in my script, then stop the video recording. I have tried something like this:

import gphoto2cffi as gp
camera = gp.Camera()
context = gp.gphoto2.VideoCaptureContext(camera)
#... wait for something, even as simple as time.sleep(7)
context.stop()

This causes the camera to record video for 1 second then stop. When the code gets to "context.stop()", it hangs.

Any thoughts about what I might be doing wrong? Python 2.7.12 libgphoto2 2. 5.10 gphoto2cffi 0.3~a1-1

Thanks, Hank

jbaiter commented 8 years ago

Can you configure the logger to use the DEBUG loglevel and run you script again? I mapped the internal logger of libgphoto2 to the Python logging system, so any errors/warnings should show up there. Just add the following two lines to the beginning of your script:

import logging
logging.basicConfig(level=logging.DEBUG)
hknox commented 8 years ago

The test script looks like this:

import time
import gphoto2cffi as gp
import logging

logging.basicConfig(level = logging.DEBUG)

camera = gp.Camera()
context = gp.gphoto2.VideoCaptureContext(camera)
time.sleep(5)
context.stop()

When I run python test_camera.py, the camera takes a 1 second video which is saved to the camera memory card. There is no output at all until about 10 seconds after the camera has clicked a second time, then I get:

DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.
DEBUG:root:Timeout while waiting for event.

Until I hit Ctl-C.

I can use the gphoto2 command line to record an unlimited video:

gphoto2 --set-config movie=1 --wait-event --set-config movie=0

will record video until I hit Ctl-C.

jbaiter commented 8 years ago

Thank you for the details, I will have a look at the gphoto2 source code and see if I'm doing anything different/wrong when recording videos.

hknox commented 8 years ago

I have debug output from the command line if that would help.

Hank

Sent from an iPhone....

On Sep 19, 2016, at 07:53, Johannes Baiter notifications@github.com wrote:

Thank you for the details, I will have a look at the gphoto2 source code and see if I'm doing anything different/wrong when recording videos.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jbaiter commented 8 years ago

Since I don't have your camera at home, that would help a great deal :-)

hknox commented 8 years ago

Here is a link (https://drive.google.com/open?id=1vAS6DpY0K_-gkGKF5M1FZdXD7Sr4sUU8thlIsLspBBs) to the debug output from the following command:

gphoto2 --set-config movie=1 --wait-event --set-config movie =0 --debug

Hank

On 2016-09-19 8:29 AM, Johannes Baiter wrote:

Since I don't have your camera at home, that would help a great deal :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jbaiter/gphoto2-cffi/issues/14#issuecomment-247979696, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNb1aRyWimEZ2SIuw736l_5FIIY9qamks5qroANgaJpZM4J_7iF.

hknox commented 7 years ago

Is there a way to capture the debug info from libgphoto2 using the cffi wrapper? The logging command I used above only seems to get the Python log output. It would be useful to see what the underlying library is doing.

jbaiter commented 7 years ago

You're right! I was convinced that I had already implemented this, but it turns out I did only half the work: The logging callback was defined, but never registered with the library! I now fixed this, so please install the latest version from github, set your logging level to DEBUG and see what the library says :-)

hknox commented 7 years ago

Here is a link to debug output: https://docs.google.com/document/d/1EEEvzcrGHz7WSdN93y9vYzE0lXtBVnCtELTX7zlJL80/edit?usp=sharing

There is an INFO:root log message where I instantiate the VideoCaptureContext, then another after that call returns. There are over 100 pages of output between the 2 root log messages, I'm not sure how to read it quickly! Does this help??

jbaiter commented 7 years ago

@hknox Sorry for not responding to your issue, I got a bit swamped in September/October and unfortunately this issue fell under the table :-( Could you please re-upload your log?