WriteData Plugin¶
The WriteData plugin implements an interface that allows writing data to a file from CVEDIA-RT data.
Adding WriteData to an instance lua code¶
To use the WriteData plugin on any instance only a few steps are needed:
Setup plugin on instance lua¶
Declare and initialize the WriteData plugin state Lua variable:
local instance = api.thread.getCurrentInstance()
api.factory.writedata.create(instance, "WriteData")
Include only once
The instance creation should be run only once, preferably on the onInit function.
Write data anywhere using the different available methods:¶
local writeInst = api.factory.writedata.get(instance, "WriteData")
--- Create a new video that will be written with frames
--- @param key string Identifier for the video
--- @param filename string Path to write the video file
--- @param width number New video width
--- @param height number New video height
--- @param fps number New video FPS
writeInst:createVideo(key,filename,width,height,fps)
--- Write a frame from specified framebuffers to a video file
--- @param key string Identifier for the video
--- @param x number New frame x pos on framebuffer
--- @param y number New frame y pos on framebuffer
--- @param width number New frame width (set at 0 to use framebuffer width)
--- @param height number New frame height (set at 0 to use framebuffer height)
--- @param sources string[] Framebuffer names to be used as sources (all will be concat'd and written as a frame)
writeInst:writeFrame(key,x,y,width,height,sources)
--- Write an image file from a specified framebuffer
--- @param x number New image x pos on framebuffer
--- @param y number New image y pos on framebuffer
--- @param width number New image width (set at 0 to use framebuffer width)
--- @param height number New image height (set at 0 to use framebuffer height)
--- @param filename string Path to write the image file
--- @param source string Framebuffer name to be used as source
writeInst:writeImage(x,y,width,height,filename,source)
--- Write a string to a file
--- @param ptr any Pointer to WriteDataManaged object
--- @param filename string Path to write the data file
--- @param sdata any Data to be written to file (String or any lua object)
writeInst:writeStructuredData(filename,sdata)
--- Write a string to a file
--- @param ptr any Pointer to WriteDataManaged object
--- @param filename string Path to write the data file
--- @param sdata string Data to be written to file
writeInst:writeText(filename,sdata)
--- Write a json string to a file
--- @param ptr any Pointer to WriteDataManaged object
--- @param filename string Path to write the data file
--- @param sdata any Lua Object to be written to file
writeInst:writeJson(filename,sdata)
--- Append a string to a newly created file
--- @param ptr any Pointer to WriteDataManaged object
--- @param filename string Path to write the data file
--- @param sdata any Data to be written to file (String or any lua object)
--- @param separator string (Optional) Separator to be written after data
writeInst:appendStructuredData(filename,sdata,separator)
--- Append a string to a file
--- @param ptr any Pointer to WriteDataManaged object
--- @param filename string Path to write the data file
--- @param sdata any Data to be written to file (String)
--- @param separator string (Optional) Separator to be written after data
writeInst:appendText(filename,sdata,separator)