gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
1.06k stars 325 forks source link

Capturing multiple images, downloading later #1051

Open cbreak-black opened 2 weeks ago

cbreak-black commented 2 weeks ago

Describe the bug

Capturing more than three images in sequence to the camera internal storage, and downloading them later fails. It seems to be related to a LRU queue in the ptp2 code. My goal is to capture an image sequence as fast as possible without spending time on downloading any data, and then downloading it later.

Name the camera This happens both with a Canon EOS 1100D and a Sony Alpha-A6000.

libgphoto2 and gphoto2 version

This problem happens both with the gphoto version bundled with ubuntu 24.04, as well as a libgphoto compiled from git:

gphoto2         2.5.28         gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2      2.5.31.1       standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.2         iolibs: disk ptpip usb1 usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, no serial

To Reproduce Steps to reproduce the behavior:

gphoto2 --capture-image --capture-image --capture-image --capture-image -L --get-file 1 --get-file 4 -L

New file is in location /capt0000.cr2 on the camera                            
New file is in location /capt0001.cr2 on the camera
New file is in location /capt0002.cr2 on the camera
New file is in location /capt0003.cr2 on the camera
There are 4 files in folder '/'.
#1     capt0000.cr2                13142 KB image/x-canon-raw 1730191963
#2     capt0001.cr2                13141 KB image/x-canon-raw 1730191970
#3     capt0002.cr2                13141 KB image/x-canon-raw 1730191976
#4     capt0003.cr2                13143 KB image/x-canon-raw 1730191983
There is no file in folder '/store_00020001'.
There is no file in folder '/store_00020001/DCIM'.
There is 1 file in folder '/store_00020001/DCIM/100CANON'.
#5     IMG_8177.CR2               rd 13466 KB image/x-canon-cr2 946687230
There is no file in folder '/store_00020001/MISC'.

*** Error ***              
You need to specify a folder starting with /store_xxxxxxxxx/
Saving file as capt0003.cr2
There are 4 files in folder '/'.
#6     capt0000.cr2                13142 KB image/x-canon-raw 1730191963
#7     capt0001.cr2                13141 KB image/x-canon-raw 1730191970
#8     capt0002.cr2                13141 KB image/x-canon-raw 1730191976
#9     capt0003.cr2                13143 KB image/x-canon-raw 1730191983
There is no file in folder '/store_00020001'.
There is no file in folder '/store_00020001/DCIM'.
There is 1 file in folder '/store_00020001/DCIM/100CANON'.
#10    IMG_8177.CR2               rd 13466 KB image/x-canon-cr2 946687230
There is no file in folder '/store_00020001/MISC'.

The most recent 3 images can be downloaded, but anything older can not. The error message makes little sense, since /store_xxxxxx should be added by libgphoto if it needs that to be in the path. If I remove the check, the error message is instead:

File '//capt0000.cr2' does not exist.

The code references an LRU queue, which seems to bypass the check for /store_ prefix, but only for the most recent frames. But the expiration itself does not seem to be camera specific.