title | description |
---|---|
setCapturerFromFile |
Configure K21 to process existing video or image files |
The setCapturerFromFile
method configures K21 to process an existing video (.mp4) or image (.png) file instead of capturing from screen. This is useful when you want to analyze pre-recorded content.
const k21 = new K21();
k21.setCapturerFromFile({
file: './recordings/screen-capture.mp4'
});
The configuration object requires the following parameter:
Parameter | Type | Required | Description |
---|---|---|---|
file |
string |
Yes | Path to the file to be processed. Must be either .mp4 or .png |
- Video files (
.mp4
) - Image files (
.png
)
k21.setCapturerFromFile({
file: './captures/meeting-recording.mp4'
});
k21.setCapturerFromFile({
file: './screenshots/dashboard.png'
});
The method will throw an error in these cases:
- If a screen capturer is already set
- If the file path is not provided
- If the file type is not supported (must be .mp4 or .png)
- If the file path is invalid
try {
k21.setCapturerFromFile({
file: './recordings/video.avi' // Unsupported format
});
} catch (error) {
console.error('Failed to set file capturer:', error.message);
// Error: File must be either .mp4 or .png
}
- You cannot use
setCapturerFromFile
if you've already set a screen capturer usingsetCapturer
- The file must exist and be accessible when the method is called
- Make sure you have appropriate permissions to read the file