Module 34: Recording VNC

Introduction

minimega supports recording and playback of both the framebuffer and keyboard and mouse interactions with VMs. Framebuffer recordings contain VNC/RFB data at 10 frames per second and can be played back in a browser or transcoded to video, such as mp4, using the rfbplay tool.

Keyboard/mouse recordings are stored in a plaintext file format and can be played back to any running VM. All VNC operations are namespace aware, and users must only specify the name of the virtual machine and minimega will automatically locate the host where the virtual machine resides.

minimega supports recording framebuffer and keyboard/mouse data with the vnc API. All recording files are stored on the host where the virtual machine is currently running. There are a few caveats to recording data using minimega, depending on on what data you are recording, described below.

You can record the keyboard, mouse, and video framebuffer for any VM running in minimega.

  • Recording will only work for noVNC run over miniweb.
  • In a mesh miniweb will only record for the node miniweb is running on. You can however run multiple miniweb sessions.
  • You can’t run a playback and do a recording at the same time.
  • You can’t have multiple recordings running at once.

Keyboard and Mouse

You can record keyboard and mouse actions to a file. For example, to record keyboard/mouse data on VM lin1, and save to lin1.vnc:

$ vnc record kb lin1 /home/ubuntu/lin1.vnc

To view active recordings run

$ vnc
host | name | type      | time         | filename
m2   | lin1 | record kb | 4.719971868s | /home/ubuntu/lin1.vnc

To stop the recording on lin1 run

$ vnc stop kb lin1

The recorded file format uses the following schema:

<time delta>:PointerEvent,<mask>,<x>,<y>
<time delta>:KeyEvent,<press>,<key>

The time delta is the time, in nanoseconds, between the previous record and this one. Users may use a time duration (e.g. “5m3s”) if generating these files manually.

For pointer events, a button mask of 0 is no buttons, 1 is left mouse, 2 right, and 3 both left and right.

For keyboard events, there is an event for a key press (press is true in the schema), and a key release. For code points not represented by ASCII, the key value is one of the codepoints defined in the minimega keydef file.

Files get very big, very quickly because you are recording mouse movements

cat /home/ubuntu/lin1.vnc | more
574598:PointerEvent,0,100,669
8436610:PointerEvent,0,103,668
7460935:PointerEvent,0,108,666
8073963:PointerEvent,0,110,665
8040223:PointerEvent,0,114,665
<snip>

As another example, the following excerpt shows several mouse movements, and someone typing foo:

178759303:PointerEvent,0,606,44
130044895:PointerEvent,1,606,44
97711488:PointerEvent,0,606,44
578412037:KeyEvent,true,f
8141459:KeyEvent,false,f
111708110:KeyEvent,true,o
10379962:KeyEvent,false,o
69607950:KeyEvent,true,o
102641640:KeyEvent,false,o
436817511:PointerEvent,0,606,43
54109:PointerEvent,0,606,41
4740247:PointerEvent,0,607,38
39063:PointerEvent,0,607,17

Lines that begin with a “#” are treated as comments and skipped.

Framebuffer

minimega records VM framebuffers (video) by connecting to the target VM using a built-in VNC/RFB client. minimega can record the framebuffer of VMs running on any minimega node, so long as it can lookup the VM using vm info, and the remote VM’s VNC port is accessible from the minimega node you are issuing the command from. There is no need to have the web service running, or to be connected to the VM in order to record framebuffer data.

minimega records framebuffer data at 10 frames per second.

For example, to record the framebuffer on VM lin1, and save to lin1.fb:

$ vnc fb record lin1 /home/ubuntu/lin1.fb
$ vnc
host | name | type      | time         | filename
m2   | lin1 | record fb | 1.159660168s | /home/ubuntu/lin1.fb

To stop recording, use the stop keyword:

$ vnc stop fb lin1

This recording is saved in a binary file.

Authors

The minimega authors

Created: 14 Jun 2017

Last updated: 3 June 2022