# Video

This function block plays a video file and outputs individual frames for processing. It lets you choose a file, control playback mode, and provides a timestamp and loop/restart information alongside each frame.

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

`Restart` This input socket accepts a boolean that, when true, restarts the video playback from the beginning. (Input socket)

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

`Image Any` Frame image read from the video. (Output socket)

`Timestamp` Human-readable timestamp for the current frame within the video. (Output socket)

`Restarted` Boolean flag that becomes true when the video reaches the end and restarts. (Output socket)

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

`Select video file` Button to choose the video file to play. (Control)

`Real-time` Switch to enable or disable real-time playback. When enabled, frames are advanced to match the original video frame rate. (Control)

## 🎨 Features <a href="#features" id="features"></a>

* Smooth playback with optional real-time synchronization so frames follow the original video timing.
* Frame-level output with a convenient timestamp string for each frame.
* Looping behavior and a restart control to reset playback from the start.
* Ability to preview or forward frames to downstream processing blocks (for example detections, logging or saving).
* Optional background frame handling for integrations that upload or log frames externally.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* When a video file is selected, the block opens it and prepares playback.
* If the `Real-time` switch is on, the block advances frames so the playback rate matches the source video's frames per second. If off, frames advance as fast as the system evaluates the graph.
* Sending a true signal to the `Restart` input will reset playback to the first frame.
* Each evaluation outputs the latest frame, a readable timestamp indicating the frame position inside the video, and a boolean indicating if the video looped or restarted.

## 📝 Usage instructions <a href="#usage" id="usage"></a>

1. Click the `Select video file` button and choose a supported video file.
2. Turn `Real-time` on if you want playback to match original speed; turn it off to step frames as fast as processing allows.
3. Optionally send a true value to the `Restart` input to reset playback.
4. Connect the `Image Any` output to visualization or analysis blocks to process each frame.

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

* Preview frames while developing: connect `Image Any` to `Show Image` to quickly inspect frames.
* Save important frames or recordings: route `Image Any` to `Image Logger` or `Record Video` to store frames or make a video file.
* Reduce processing load: add an `Image Resizer` or `Image Resize` block before heavy analysis blocks (for example `Object Detection` or `Pose Estimation`) to lower resolution and increase throughput.
* Improve detection quality: to denoise them with `Denoising` before object/pose models.
* Background subtraction workflows: combine with `Background Subtractor` to detect moving objects before sending results to `Object Detection` or `Blob Detector`.
* Region-limited processing: use `Image ROI Select` or `Image ROI` to crop to areas of interest and then run `Find Object`, `Mask Detection` or OCR blocks for focused analysis.
* Tracking and analytics: pair `Object Detection` (or `Object Detection - Custom`) with `Object_Detection_Tracker` to track detections across frames and feed the tracker output to analysis blocks like `Traffic Intersection Analysis`.
* Text extraction: use `OCR` or `OCR (EasyOCR)` on frames (optionally after cropping with `Image ROI Select`) to read printed labels or timestamps.

(hint) When working with long videos, consider turning off `Real-time` during configuration and testing to iterate faster; switch it on for timed playback during final runs.

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

* No frames appear: ensure a valid video file was selected with `Select video file` and that the file is accessible.
* Playback too slow: if `Real-time` is enabled but system cannot keep up, try disabling `Real-time` or reduce the frame size with `Image Resizer`.
* Video restarts unexpectedly: the end-of-file triggers a restart flag on output; use the `Restart` input to explicitly control playback position.
* Timestamps seem off: timestamps are calculated relative to the video duration; verify the chosen file's metadata and try a different file if values appear incorrect.

If you plan to stream frames into cloud or logging services, combine the block with `Image Logger`, `Record Video`, or other export blocks to persist results.


---

# 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/image-inputs/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.
