File watchers are the glue between "I recorded something" and "my pipeline processes it." They monitor directories for changes and execute actions when new files appear. For video production automation, a file watcher is the trigger mechanism that eliminates the manual "now run the pipeline" step from your workflow.
File Watcher Options by Platform
Linux: inotify
The kernel-level file notification system. inotifywait (from the inotify-tools package) provides a command-line interface:
# Install
sudo apt install inotify-tools
# Watch for new video files
inotifywait -m -e close_write --include '\.(mp4|mkv|mov|webm)$' /path/to/watch/
Advantages: kernel-level performance, no polling, zero CPU usage while waiting. Limitation: does not work across network filesystems (NFS, CIFS) without polling fallback.
macOS: FSEvents / fswatch
# Install fswatch
brew install fswatch
# Watch directory
fswatch -0 /path/to/watch/ | while read -d "" event; do
echo "File changed: $event"
done
Cross-Platform: Node.js with chokidar
const chokidar = require('chokidar');
const watcher = chokidar.watch('/path/to/watch/', {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true,
awaitWriteFinish: {
stabilityThreshold: 2000, // wait 2s after last write
pollInterval: 100
}
});
watcher.on('add', (filePath) => {
console.log('New file:', filePath);
processVideo(filePath);
});
The awaitWriteFinish option is critical for video files. Without it, the watcher fires when the file first appears, while it is still being written. A 500MB screen recording that takes 10 seconds to copy would trigger processing on a partial file.
Building the Trigger-to-Pipeline Connection
The file watcher is just the trigger. The connection to your video pipeline needs to handle:
- File validation: Is this a valid video file? Check the header bytes, not just the extension.
- Queue management: If 5 files drop simultaneously, process them sequentially to avoid resource contention.
- Status tracking: Which files are queued, processing, completed, or failed?
- Error recovery: If processing fails, retry once with a delay, then move to a failure directory.
A Complete Watcher Service
// Using PM2 to keep the watcher running as a service
// ecosystem.config.js
module.exports = {
apps: [{
name: 'video-watcher',
script: 'watcher.js',
watch: false, // don't watch the watcher script itself
max_restarts: 10,
restart_delay: 5000,
env: {
WATCH_DIR: '/home/user/video-pipeline/input',
OUTPUT_DIR: '/home/user/video-pipeline/output',
PIPELINE_CONFIG: '/home/user/video-pipeline/config.yaml'
}
}]
};
Integration With VidNo
VidNo's local-first architecture makes it a natural target for file watcher triggers. When a new screen recording appears in the watched directory, the watcher invokes VidNo's processing pipeline. The pipeline runs OCR, generates the narration script via Claude API, synthesizes voice, edits with FFmpeg, and outputs the finished video -- all triggered by a single file drop.
Monitoring Your Watcher
| What to Monitor | Why | How |
|---|---|---|
| Watcher process health | If it crashes, nothing processes | PM2 or systemd with auto-restart |
| Queue depth | Growing queue means processing is too slow | Count files in processing directory |
| Disk space | Raw video files fill disks fast | Alert at 80% capacity |
| Processing duration | Anomalous times indicate issues | Log timestamps per pipeline run |
A file watcher turns your video production pipeline from a tool you run into a service that runs. The difference is whether you have to remember to process recordings or whether recordings process themselves.