<commit_before>// This module is responsible for capturing videos

'use strict';

const config = require('config');
const PiCamera = require('pi-camera');
const myCamera = new PiCamera({
  mode: 'video',
  output: process.argv[2],
  width: config.get('camera.videoWidth'),
  height: config.get('camera.videoHeight'),
  timeout: config.get('camera.videoTimeout'),
  nopreview: true,
});

process.on('message', (message) => {
  if (message.cmd === 'set') {
    myCamera.config = Object.assign(myCamera.config, message.set);
  }
  else if (message.cmd === 'capture') {
    myCamera.record()
      .then((result) => process.send({
        response: 'success',
        result,
        error: null,
      }))
      .catch((error) => process.send({
        response: 'failure',
        error,
      }));
  }
});<commit_msg>Add minor delay to video capture. Hopefully this helps the camera moduel keep up.<commit_after>// This module is responsible for capturing videos

'use strict';

const config = require('config');
const PiCamera = require('pi-camera');
const myCamera = new PiCamera({
  mode: 'video',
  output: process.argv[2],
  width: config.get('camera.videoWidth'),
  height: config.get('camera.videoHeight'),
  timeout: config.get('camera.videoTimeout'),
  nopreview: true,
});

process.on('message', (message) => {
  if (message.cmd === 'set') {
    myCamera.config = Object.assign(myCamera.config, message.set);
  }
  else if (message.cmd === 'capture') {
    setTimeout(() => {
      myCamera.record()
        .then((result) => process.send({
          response: 'success',
          result,
          error: null,
        }))
        .catch((error) => process.send({
          response: 'failure',
          error,
        }));
    }, 500);
  }
});
{'fraction_non_alphanumeric': 0.17084282460136674, 'fraction_numerical': 0.0028473804100227792, 'mean_word_length': 3.0765661252900234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4968376', 'n_tokens_mistral': 531, 'n_tokens_neox': 523, 'n_words': 129}