Screen recording module - General Discussion and Assistance - CHDK Forum

Screen recording module

  • 2 Replies
  • 429 Views
*

Offline reyalp

  • ******
  • 13387
Screen recording module
« on: 16 / May / 2021, 03:04:09 »
Advertisements
I realized it would be relatively easy to hijack live_view_get_data to record the live view stream on camera in chdkptp lvdump format, so here's an initial messy implementation of a module that does that.

It works similarly to memory dump: Set the debug action to ScrDump, set the settings in the "Dump Screen" menu item, and use the debug shortcut to start.

I'm not sure it makes sense as a module, maybe it would be better to just do as a compile time define.
Don't forget what the H stands for.

Re: Screen recording module
« Reply #1 on: 16 / May / 2021, 04:10:32 »
@reyalp

Assuming I'm reading it right, a similar feature exists in ML, ie if selected a screen grab will take place in 10 seconds.

It might be a good idea to create a module of the feature, as then anyone who doesn't compile and wishes to use it can simply add it to the CHDK module folder.


I’m not sure what LV dump format means. A dump option for still or video capture would be great.
« Last Edit: 16 / May / 2021, 05:29:18 by pigeonhill »

*

Offline reyalp

  • ******
  • 13387
Re: Screen recording module
« Reply #2 on: 01 / June / 2021, 01:31:06 »
I added a different version of this in trunk 5932. It's currently somewhat more awkward to use than the original version, but doesn't require changes to the core beyond some exports. I have some ideas to make it less clunky, but it's a niche use case and I wanted to get it into SVN.

It's implemented as a "menu module" which appears Miscellaneous stuff -> Tools.

The module starts running as soon as you enter the menu.

The menu has the following entries:
Schedule dump - when this is selected, the menu closes and the dump starts as specified in the following options:
* Frames - number of frames to capture, default 1
* Frame Time (ms*10) - The time between frames, as 10s of milliseconds
* Framebuffers - viewport, bitmap or both
* Skip palette - don't capture the palette when capturing the bitmap (Pre digic 6 cameras only)
* Skip opacity - don't capture the opacity buffer when capturing the bitmap (Digic 6 and later only)
* Dump start delay - The delay after selecting "schedule dump" before the recording starts

Finally, there is an "Exit module" item. This ends the module task and unloads the module. Exiting the menu using other methods (back, hitting the alt button, or scheduling a dump) do not end the module. This is intentional, it does not use conf for settings, so if you exit the module, options reset to default.

The capture functionality is implemented in a separate task, which sits in a loop waiting for commands or grabbing frames. This allows it to capture at fairly regular frame rates without hooking into spytask or kbd_task.


Some possible improvements
A hotkey
Some kind of status feedback, but not be displayed when actually grabbing frames!
Image capture (netpbm like chdkptp should be fairly easy)

Recent additions to chdkptp allow extracting / converting captured dumps. For example, the attached was converted with
Code: [Select]
lvdumpimg -bm -pipebm=combine -pipevp -infile=elph130-scrdump-0001.lvdump -vp='convert - -resize 640x480! -layers merge scrdump-menu.png'
You can also extract Y,U,V values as PGM or raw data, or interactively inspect in chkdptp:
Code: [Select]
___> !lv=lvutil.live_wrapper()
___> !lv:replay_load('sx710-0003.lvdump')
___> !return lv:replay_get_frame_count()
=20
___> !lv:replay_seek('set',10) return lv.replay_pos
=10
___> !lv:replay_frame()
___> !return lv.vp.fb_type_info.chdk_name, lv.vp.fb_type_info.format, lv.vp.visible_width, lv.vp.visible_height
="LV_FB_YUV8B","yuv422",640.0,480.0
___> !h=lv.vp:get_histo_y() h:print{bin=16,fmt='%#!'}
  0- 15
 16- 31 ################################################################
 32- 47 ################################################################################################
 48- 63 ##############
 64- 79 #################
 80- 95 #############
 96-111 ########
112-127 ####
128-143 ####################################################################################################
144-159 ##############################################
160-175
176-191
192-207
208-223
224-239
240-255
___> !lv:dumpimg_init({vp={format='yuv-s-pgm',filespec="sx710-${frame}-${channel}.pgm"}})
___> !lv:dumpimg_frame()
___> !lv:replay_frame()
___> !lv:dumpimg_frame()
___> !os.execute('ls sx710-*.pgm')
sx710-000001-u.pgm  sx710-000001-v.pgm  sx710-000001-y.pgm  sx710-000002-u.pgm  sx710-000002-v.pgm  sx710-000002-y.pgm
___> !lv:dumpimg_finish()
___> !lv:replay_end()

I’m not sure what LV dump format means. A dump option for still or video capture would be great.

lvdump is a minimal format used by chdkptp to record the CHDK live view protocol. It contains the various frame buffers along with data sufficient to render them (mostly) as they appear on the camera screen.

Properly rendering PNGs or jpegs on the camera would require a lot of work in a very constrained environment. A simple format would like ppm would more doable, but on most cameras it would take considerable effort to get aspect rations, scale and alignment between live view and UI correct.
Don't forget what the H stands for.

 

Related Topics