lvdump to SD card usign remote lua - RAW Shooting and Processing - CHDK Forum

lvdump to SD card usign remote lua

  • 7 Replies
  • 1957 Views
*

Offline obi

  • *
  • 27
lvdump to SD card usign remote lua
« on: 30 / January / 2023, 05:30:00 »
Advertisements
Hi guys, I wanted to know if there is a possibility to trigger and store (using remote lua) the lvdump files on the Camera's SD card itself. I was looking into the modules/scrdump.c file but couldn't really figure out what is going on there. It does seem to write to files under A/DCIM/100CANON/CRW_%04d.JPG but I don't see the files on the SD and also could not find out in the code if and when these files are cleaned up. Any tips would be appreciated.

*

Offline reyalp

  • ******
  • 14082
Re: lvdump to SD card usign remote lua
« Reply #1 on: 30 / January / 2023, 13:11:56 »
Hi guys, I wanted to know if there is a possibility to trigger and store (using remote lua) the lvdump files on the Camera's SD card itself. I was looking into the modules/scrdump.c file but couldn't really figure out what is going on there. It does seem to write to files under A/DCIM/100CANON/CRW_%04d.JPG but I don't see the files on the SD
You mean you've triggered a screen dump in the UI, and the files don't get created? Or are you trying to trigger it from Lua somehow?
Quote
and also could not find out in the code if and when these files are cleaned up. Any tips would be appreciated.
There is nothing in the files that would clean them up automatically.

The module is intended to be set up from the menu (background https://chdk.setepontos.com/index.php?topic=14347.msg146339#msg146339) so some work would be needed to trigger it from Lua. You could probably make a variant of scrdump_schedule that took the values from Lua.

Also note it currently does not record when the camera is recording video. This is because the cameras generally block other filesystem access when recording video, as well as the likelihood the bandwidth needed for screendump would interfere. It's possible enabling unsafe IO in the misc menu would handle the first issue, the module is currently hard coded not to record in video.
Don't forget what the H stands for.

*

Offline obi

  • *
  • 27
Re: lvdump to SD card usign remote lua
« Reply #2 on: 30 / January / 2023, 14:30:06 »
Thanks for the reply.

Manually triggering in the UI do create those files in there. The confusion was because the lvdump over chdkptp doesn't result in any file on the SD card itself.

I was indeed hoping that I could trigger the screen dump using a lua script running on the camera (of course not during video recording as you mentioned). I will look into the scrdump_schedule function.

How can I easily view for example the CRW_0001.JPG resulting from a manual capture on under Linux?

*

Offline reyalp

  • ******
  • 14082
Re: lvdump to SD card usign remote lua
« Reply #3 on: 30 / January / 2023, 15:23:38 »
Manually triggering in the UI do create those files in there. The confusion was because the lvdump over chdkptp doesn't result in any file on the SD card itself.
Right, lvdump in chdkptp streams it directly over USB, without writing to the SD card. The live view over PTP actually came first, I only realized much later that I could use the same code to record on camera for debugging. That's why the module has a dummy PTP structure.

Quote
I was indeed hoping that I could trigger the screen dump using a lua script running on the camera (of course not during video recording as you mentioned). I will look into the scrdump_schedule function.
It's a bit ugly since it's set up to run as a standalone "simple module" from the tools menu. For quick and dirty implementation, you could probably just copy most of the code (except the module / menu stuff) into luascript.c, and then add a lua function to set the parameters and kick off the task. One thing you'd want to watch out for is making sure the Lua module doesn't unload before the task exits.

Alternately, you could just grab the code to write the header (in scrdump_start) and the code to write individual frames (scrdump_frame) and have the Lua script handle scheduling. This would probably be simpler, and your Lua API could be something like
scrdump_open("filename")
while whatever
 scrdump_frame()
scrdump_close()

Or you could even re-use Lua io filehandles for the file, write the header using Lua, and just do scrdump_frame(filehandle, framebuffer flags)

This last option would add very little size to the module, so I might be tempted to add it to the official source. The downside is your script would be responsible for capturing each frame.

Quote
How can I easily view for example the CRW_0001.JPG resulting from a manual capture on under Linux?
You can use chdkptp, either in the gui from the live view tab, under "debug" "Play from file" or use lvdumpimg to either generate netpbm files of the frames, or pipe through imagemagic or ffmpeg to produce other formats.

Note that the lvdumpimg option requires building chdkptp from current source (I *really* need to do another release  :-[), but the CLI is quite easy to build. GUI playback should work with the current binary builds.

Note that the current lvdump format has no time coding, so playback framerate is entirely unconnected to recording frame rate.
Don't forget what the H stands for.


*

Offline obi

  • *
  • 27
Re: lvdump to SD card usign remote lua
« Reply #4 on: 30 / January / 2023, 16:11:12 »
Thanks. With my very limited knowledge, I will need time to digest and implement something along the lines you mentioned.

However I was still not able to view that CRW_000X.JPG that results when I do a manual capture using the UI.

The lvdumpimg works fine as I use the 1.6 self compiled version of CHDK. When I do the following on the chdkptp CLI, the ppm file is directly viewable.

lvdumpimg -vp=vp_${date,%Y%m%d}/${date,%H%M%S}/${frame}.ppm -count=1

However the CRW_0001.JPG resulting from a viewport capture using the UI is not viewable. I tried to use the convert command and even moved JPG to PPM to see if it makes any difference but no difference. Not sure what am I missing. Maybe  lvdumpimg is removing the header which I somehow need to get rid of.

*

Offline obi

  • *
  • 27
Re: lvdump to SD card usign remote lua
« Reply #5 on: 30 / January / 2023, 16:37:54 »
ahh you mean chdkptp latest sources and not chdk. I will now check it out.

*

Offline reyalp

  • ******
  • 14082
Re: lvdump to SD card usign remote lua
« Reply #6 on: 30 / January / 2023, 16:42:03 »
However the CRW_0001.JPG resulting from a viewport capture using the UI is not viewable. I tried to use the convert command and even moved JPG to PPM to see if it makes any difference but no difference. Not sure what am I missing. Maybe  lvdumpimg is removing the header which I somehow need to get rid of.
How are you trying to view / convert the CRW_0001.JPG?

Note it is NOT a jpeg file, it's a chdkptp format lvdump file, it's just named like an image so a user could download it over regular PTP. It should be in exactly the same format as chdkptp lvdump records.

ahh you mean chdkptp latest sources and not chdk. I will now check it out.
Yes, to use lvdumpimg with an input file, you need to build chdkptp from current svn.
Don't forget what the H stands for.

*

Offline obi

  • *
  • 27
Re: lvdump to SD card usign remote lua
« Reply #7 on: 30 / January / 2023, 17:09:58 »
Thanks. Compiled the latest chdkptp (needed to install liblua5.3-dev and run misc/setup-ext-libs.bash) and found out the lvdumpimg -infile option. Works as you described.

Need to now see how I can easily get the lvdumps done periodically, while the user is doing some things on the camera except during video recording.


 

Related Topics