Camera.record
readonly |
Returns a table containing two functions to control video recording:
record.start(options): starts recording to a file. The options argument is a table with the following fields:file (required): the destination file path as a string. The extension determines the container format: .mp4, .wmv, or .aviformat (optional): the video encoding quality as a string, one of "Auto", "VGA", "HD720p" (default), "HD1080p", "UHD2k", "UHD4k"video (optional): the video bitrate preset as a string, one of "low" (1 Mbps), "medium" (2 Mbps), "high" (5 Mbps, default), "ultra" (10 Mbps)audio (optional): the audio bitrate preset as a string, one of "low" (64 kbps), "medium" (128 kbps, default), "high" (192 kbps), "ultra" (256 kbps)
record.stop(): stops the current recording session. Has no effect if no recording is active.
- Calling
record.start() while already recording will automatically stop the previous session before starting a new one. - Audio is always recorded in stereo at 44100 Hz sample rate.
- Raises an error if the
file field is missing or the file extension is not supported.
Example
--! luart-extensions
import capture
local cam = capture.Camera()
-- Start recording an MP4 at 1080p with high video bitrate
cam.record.start {
file = "output.mp4",
format = "HD1080p",
video = "high",
audio = "medium"
}
print("Recording 5sec...")
sleep(5000)
cam.record.stop()
print("Recording stopped")