Webcam Recorder for LabVIEW
============================

A standalone Windows webcam recorder controlled by LabVIEW (or any process
that can launch executables and write text files).

INSTALLATION
------------
1. Unzip this archive anywhere (e.g. C:\Tools\WebcamRecorder).
2. The executable is WebcamRecorder.exe inside the unzipped folder.
3. First launch: Windows SmartScreen may show "Unknown publisher".
   Click "More info" -> "Run anyway". Only needed once per machine.

QUICK TEST
----------
Double-click test-launch.bat to verify the camera works.
A small video window appears in the top-right of the screen.
Create C:\temp\stop.flag (any contents) to stop and save the test recording
to C:\temp\test_recording.webm.

COMMAND LINE
------------
  WebcamRecorder.exe ^
    --output="C:\path\to\out.webm" ^
    --stop-flag="C:\path\to\stop.flag" ^
    [--label-file="C:\path\to\label.txt"] ^
    [--camera="<substring of camera name>"] ^
    [--quality=480p|720p|1080p] ^
    [--x=N --y=N --width=N] ^
    [--list-cameras]

Required:
  --output       Path to the .webm file to create. Parent folder must exist.
  --stop-flag    Path the app watches. When this file appears, recording stops.

Optional:
  --label-file   Path to a UTF-8 text file. Whatever text it contains is
                 burned into the top-left corner of the video, updated live
                 (poll interval ~200 ms). Empty file = no label drawn.
  --camera       Substring match against camera names (case-insensitive).
                 Default: system default camera.
  --quality      480p (640x480), 720p (1280x720), or 1080p (1920x1080).
                 Default: 720p. Affects recorded file, not preview window.
  --x, --y       Window top-left position in screen pixels.
                 Default: top-right corner of primary monitor.
  --width        Initial window width (height locked to camera aspect).
                 Default: 160. Min 80, max 800.
  --list-cameras Prints "<deviceId>\t<label>" lines to stdout, then exits.

OVERLAYS BURNED INTO VIDEO
--------------------------
  Top-left:    text from --label-file (live, wraps to multiple lines)
  Bottom-left: live system clock, format YYYY-MM-DD HH:MM:SS

PREVIEW WINDOW
--------------
  - Always on top (floats over LabVIEW and other windows)
  - Frameless: drag from anywhere on the video to move it
  - Resizable from the corners (aspect ratio locked)
  - Right-click menu: Reset size / Reset position / Close

EXIT CODES
----------
  0  success (stop-flag detected, file saved cleanly)
  1  generic argument error
  2  no camera available
  3  --camera name did not match any device
  4  --output path not writable
  5  --stop-flag folder does not exist
  6  camera disconnected during recording

OUTPUT FORMAT
-------------
WebM container (VP9 video + Opus audio).
Plays in VLC, Chrome, Firefox, ffmpeg, and Windows Media Player (with codec).
Written incrementally: a forced kill leaves a playable partial file.

LABVIEW EXAMPLE SEQUENCE
------------------------
  1. Use System Exec.vi (asynchronous) to launch:
       WebcamRecorder.exe --output="C:\data\run42.webm"
                          --stop-flag="C:\lab\control\stop.flag"
                          --label-file="C:\lab\control\label.txt"
                          --quality=1080p

  2. Write to label file to set the on-screen label:
       Write-Text-File.vi -> "C:\lab\control\label.txt" <- "Scene 1: warm-up"

  3. Change label any time:
       Write-Text-File.vi -> "C:\lab\control\label.txt" <- "Scene 2: sample loaded"

  4. Stop recording:
       Write-Text-File.vi -> "C:\lab\control\stop.flag" <- ""
     The app finalizes the video, deletes stop.flag, and exits with code 0.

NOTES
-----
- The recorded file is always at full --quality resolution. The window size
  is just a viewport for monitoring.
- This binary is unsigned. If your IT policy blocks unsigned executables,
  contact us about code signing.
- Fully offline. No network access required or attempted.
