# Record Video

This function block saves incoming image frames into a video file. You can start and stop recording with a boolean trigger or use the built‑in Spacebar trigger. Several quality modes are available, including a high-compression option that uses ffmpeg if installed.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Frame` The input image frames to be recorded.

`Record` Boolean control to start/stop recording (used depending on chosen trigger mode).

`Folder Path` The folder where recorded videos will be saved.

`File Name (no extension)` Optional file name base. If left empty, a timestamp will be used.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

This function block does not provide outputs.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Video Quality` Choose from quality modes:

* `Compressed` smaller files, fast.
* `High Quality` less compression, better visual fidelity.
* `High-Compress(requires ffmpeg)` best compression but requires ffmpeg available on the system.

`Trigger Mode` Choose how recording is started/stopped:

* `Spacebar` press space to toggle start/stop (requires keyboard hook availability on your OS).
* `Continuous` provide TRUE to start and FALSE to stop.
* `Once` a rising TRUE starts recording and a subsequent TRUE stops and saves.

`Recording` LED Visual indicator showing whether recording is active.

## 🎯 Key Features <a href="#features" id="features"></a>

* Start/stop recording using three trigger modes (Spacebar, Continuous, Once).
* Multiple quality modes including an optional ffmpeg-based high compression.
* Automatically picks available video codecs and container types for portability.
* Prevents opening the video while recording (to avoid file conflicts).
* Background conversion for high-compress mode so compression does not block real‑time capture (requires ffmpeg).

## 📝 How to use <a href="#usage" id="usage"></a>

1. Provide image frames to `Frame` (for example from `Camera USB`, `Camera IP (ONVIF)`, or `Stream Reader`).
2. Set the `Folder Path` where videos should be saved.
3. Optionally set `File Name (no extension)` or leave empty to use a timestamp.
4. Select desired `Video Quality`. If you need smallest files and highest compression, pick the high-compress option and ensure ffmpeg is installed.
5. Choose `Trigger Mode`:
   * For quick keyboard control use `Spacebar` (works when permitted on your OS).
   * For programmatic control use `Continuous` or `Once` and feed boolean values into `Record`.
6. Start the recording according to the selected trigger. The `Recording` LED will turn on while capturing.
7. Stop recording and let the block finalize the video. If high-compress mode was selected, final compression may run in the background.

## 📊 Behavior while running <a href="#evaluation" id="evaluation"></a>

* When recording is active, incoming frames from `Frame` are appended to the open video file.
* On stop, the file is closed. If the high-compress option was selected and ffmpeg is present, an optional background conversion will be launched to create a smaller highly‑compressed file.
* If the Spacebar trigger is unavailable (common on some Linux setups without root privileges), the block will warn and you can use `Continuous` or `Once` modes instead.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To record from a local camera, connect `Camera USB` or `Camera USB External` to the `Frame` input.
* For network cameras, use `Camera IP (ONVIF)` or `Stream Reader` as a source for smoother background frame fetching.
* Preview frames live by sending the same source into the `Show Image` block alongside this block.
* Save individual frames for inspection in parallel using `Image Logger` or `Image Write` while the block records video.
* Trigger recording automatically when something important appears by connecting detection blocks (for example `Object Detection` or `Mask Detection`) to a logic flow that drives the `Record` input.
* Use `Keyboard/Barcode Reader` if you need more complex keyboard or external input triggers routed into the `Record` input.
* If you need smaller storage footprint but still want decent quality, choose `High-Compress(requires ffmpeg)` and install ffmpeg on the system PATH.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Spacebar trigger not working on Linux: run Studio with elevated privileges (or use `Continuous`/`Once` modes).
* Compression not available: ensure ffmpeg is installed and accessible on the system PATH to enable the high-compress option. If ffmpeg is missing, the block will fallback to a non-ffmpeg mode and warn you.
* File in use while recording: the video file cannot be opened by other applications during recording. Wait until recording finishes.
* No frames saved: verify the source connected to `Frame` is providing valid images (preview with `Show Image` can help).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/input-output/outputs-exports/record-video.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
