Video recording

Namespace: recorder Language: Lua Type: Defold Lua File: record_script_extension.cpp Source: engine/record/src/record/record_script_extension.cpp

Record the game window to an MP4 file. One recording may run at a time, shared with the engine’s HTTP recording service.

Recording is supported by desktop debug engines. The module is omitted from release, headless, mobile and web builds, and when recording is excluded through an app manifest. Unsupported desktop operating systems or capture environments return an error from [ref:recorder.start]. Application audio support depends on the platform; audio is disabled by default.

API

recorder.EVENT

Type: ENUM recording events

Members

recorder.options

Type: STRUCT recording options

Members

recorder.result

Type: STRUCT recording event result

Members

recorder.start

Type: FUNCTION Starts an asynchronous recording of the game window at its native pixel size. The caller owns the output file, which remains on disk after engine shutdown. An existing file at the specified path may be overwritten. A successful return only means the request was accepted. The callback receives recorder.EVENT_STARTED when capture starts, followed by recorder.EVENT_STOPPED or recorder.EVENT_ERROR. Startup failure produces only EVENT_ERROR. Callbacks run during engine update, never inside start/stop. Window resizing stops and finalizes the recording. Deleting the calling script discards its callback but does not stop recording. Engine shutdown finalizes recording without invoking callbacks.

Parameters

Returns

Examples

local ok, err = recorder.start({
    path = sys.get_save_file("my_game", "capture.mp4"),
    fps = 30,
    audio = false,
}, function(self, event, result)
    if event == recorder.EVENT_STOPPED then
        print("Saved:", result.path)
    elseif event == recorder.EVENT_ERROR then
        print(result.error)
    end
end)
if not ok then print(err) end

recorder.stop

Type: FUNCTION Requests finalization of the current recording, including one started through HTTP. Wait for recorder.EVENT_STARTED before calling stop for a Lua recording. The original start callback receives recorder.EVENT_STOPPED only after the MP4 is finalized and ready to read, or recorder.EVENT_ERROR on failure. Returns an error if no recording is active or an operation is pending.

Returns