gphoto2 icon indicating copy to clipboard operation
gphoto2 copied to clipboard

Support changing config while capturing a movie

Open chris-morgan opened this issue 2 years ago • 0 comments

I use gphoto2 to produce a webcam stream from my camera (with the usual v4l2loopback dance).

I want to be able to configure my camera while using it as a webcam, partly to avoid disruption and partly so I can immediately see the impact of my config changes. I see no obvious reason why this shouldn’t work on at least most devices, given that over PTP --capture-movie is just grabbing frames in a loop, so you should be able to just inject configuration instructions in between frame grabs. But when I use gphoto2 --capture-movie, it takes exclusive control of the camera, and gphoto2 --set-config … doesn’t work.

I have two solutions in mind:

  1. Automatic: make gphoto2 instances cooperate so that a subsequent gphoto2 invocation attempting to communicate with the camera to get or set config does so via the one that’s capturing a movie, so that it all just works as though exclusive locks weren’t being taken. This would be the most immediately useful for users.

  2. Manual: make --capture-movie and --shell mutually compatible in some way. e.g. gphoto2 --capture-movie --stdout --shell-input=/dev/fd/3 --shell-output=/dev/fd/4. This could be useful for more advanced scripting. The general idea is that, after capturing every frame, it would flush the --shell-input file, evaluating any new commands that have come in, piping the shell output to the --shell-output file if specified, or stdout if not. Then, after it’s finished processing all of that, it continues to capture the next frame.

Much of the implementation of the manual solution could readily be used as the foundation for the friendlier automatic solution: have gphoto2 --capture-movie establish a named pipe in a known location (e.g. $XDG_RUNTIME_DIR/gphoto2-$device under Linux), and make subsequent gphoto2 --set-config, gphoto2 --shell, &c. invocations look for that and feed their commands through that if it exists, rather than trying the camera directly.

(I am immensely surprised to have found no evidence of any similar feature request or even discussion of the lack, anywhere, given that adjusting webcam parameters while capturing is standard fare on regular webcams under Windows at least, and seems a very obvious thing to want to do.)

chris-morgan avatar Jul 05 '21 08:07 chris-morgan