Gnash 0.8.7: screenshots

The next version of Gnash has the ability to save screenshots in PNG format. You can either do this through a GUI (Ctrl-O) or by specifying frames on the command line. For the command line, there are two new options: --screenshot and --screenshot-file.

To use this function properly, you should be aware of what a 'frame' means. SWFs define a sequence of frames. It's possible to extract those frames from a SWF using a tool like swfextract (from swftools), but the extracted frame may not look much like it does when you run the SWF.

This is because the defined order of those frames is not necessarily the order of execution. User input, network connections, loaded data and ActionScript contribute to how those frames look and what order they appear in (if they appear at all).

Gnash understands frames in the sequence determined by execution, not how they are ordered in the SWF. A SWF may stay on its first frame for ever while it waits for user input. Not all SWFs reach the final frame in play mode, so there is not necessarily a clear last frame. Some frames will never be reached or depend on ActionScript for the execution path.

Bearing this in mind, to make a screenshot of the 1st, 100th, and final execution frame, you can use the following command:

gnash --screenshot=1,100,last --screenshot-file screen-%f.png --once file.swf

This is only safe as long as you know the SWF will reach an exit point. If not, you can add the following option:

--max-advances 101

to ensure Gnash exits after the 101st frame advance. It is also possible to set a timeout in seconds to handle SWFs with very slow framerates:

--timeout 10

The screenshot taken with "last" is always the final frame before exit, regardless of what made Gnash exit.

The %f token in the screenshot filename will be replaced with a frame identifier (either the frame advance number or "last") so that multiple screenshots are identifiable and don't overwrite previous ones.