Screen recording module - General Discussion and Assistance - CHDK Forum
supplierdeeply

Screen recording module

  • 7 Replies
  • 5574 Views
*

Offline reyalp

  • ******
  • 14119
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

  • ******
  • 14119
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.

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
Re: Screen recording module
« Reply #3 on: 08 / November / 2021, 11:51:00 »
Quote
Some possible improvements
A hotkey
Maybe some cams somehow could use  :-[
//#define BATTCOVER_FLAG      0x00800000 // Found @0xff63663c, levent 0x205
All lifetime is a loan from eternity.


*

Offline December172

  • *
  • 34
  • A student interested in the Canon P&S hack
Re: Screen recording module
« Reply #4 on: 30 / October / 2022, 06:20:35 »
A question: how to view my captured picture(or frame sequence) on my computer?
Or how can I convert the frames to the PNG or JPEG format?
Thx
Canon PowerShot ELPH 180 (IXUS 175).
(Seems most of you are older than me.... Anyone teen? )

*

Offline reyalp

  • ******
  • 14119
Re: Screen recording module
« Reply #5 on: 30 / October / 2022, 14:55:11 »
A question: how to view my captured picture(or frame sequence) on my computer?
Or how can I convert the frames to the PNG or JPEG format?
The format is the same as used by chdkptp lvdump. If you use the current SVN version of chdkptp, you can use the lvdumpimg command to convert. Use help lvdumpimg for details. There are some additional details and examples in USAGE.TXT under "Grabbing images from the camera display"

The most recent binary release (r964) doesn't include support for using lvdumpimg from a file (only directly from a camera), but you can replay the dump in the GUI and create screenshot from there.

If you want to write your own conversion tool, the lvdump format consists of a small header described in chdkptp lua/lvutil.lua and then a series of frames, each preceded by the frame length. The frames are in the CHDK live view format, as described in CHDK core/live_view.h
Don't forget what the H stands for.

*

Offline December172

  • *
  • 34
  • A student interested in the Canon P&S hack
Re: Screen recording module
« Reply #6 on: 30 / October / 2022, 22:49:11 »
The format is the same as used by chdkptp lvdump. If you use the current SVN version of chdkptp, you can use the lvdumpimg command to convert. Use help lvdumpimg for details. There are some adlditional details and examples in USAGE.TXT under "Grabbing images from the camera display"
Hm...When I use 'lvdumpimg -vp=vp.jpg -bm=bm.jpg' command I got two pictures: the vp.jpg is a picture of my cam's current showing picture(but because of resolution,the image looks not good as on my camera's screen),without any canon OSD or CHDK OSD,only picture.The other bm.jpg can't be displayed because it hasn't a vaild jpeg format.
Questions: 1. How to get a screen dump contains canon OSD and CHDK OSD?
2.How to make the vp.jpg looks like the picture my camera screen? The vp.jpg is 720x240,but my camera resolution is 360x240.
Canon PowerShot ELPH 180 (IXUS 175).
(Seems most of you are older than me.... Anyone teen? )

*

Offline reyalp

  • ******
  • 14119
Re: Screen recording module
« Reply #7 on: 31 / October / 2022, 03:22:30 »
Hm...When I use 'lvdumpimg -vp=vp.jpg -bm=bm.jpg' command I got two pictures: the vp.jpg is a picture of my cam's current showing picture(but because of resolution,the image looks not good as on my camera's screen),without any canon OSD or CHDK OSD,only picture.The other bm.jpg can't be displayed because it hasn't a vaild jpeg format.
lvdumpimg doesn't know how to create jpegs, as described in the documentation, it only creates netpbm files. Your image viewer probably understands the ppm used for the viewport even though the extension is wrong, but not pam from the bitmap (the bitmap is in pam format because it includes transparency)

You can use a program like imagemagick to convert to more common formats and scale to the appropriate size. There are some examples USAGE.TXT

Quote
2.How to make the vp.jpg looks like the picture my camera screen? The vp.jpg is 720x240,but my camera resolution is 360x240.
The actual camera buffer is YUV (411 for cameras before digic 6). When lvimgdump creates an RGB image, the width is the number of Y values. Note that on most pre-digic 6 cams, the pixels aren't square (A 4:3 screen with square pixels would be 320x240, not 360), so to get a correct image, you need to scale it anyway.
Don't forget what the H stands for.


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal