# Frame Buffer

> **Deprecation Notice**
> This page describes features that have been removed or replaced in Luxonis Hub. Functionality may be limited and only available
to Hub Original customers. Please refer to the up-to-date guides to provision devices, manage fleets, and deploy applications.

Buffers h264 frames and creates and sends a video to Luxonis Hub.

> Make sure to use the
> `add_frame()`
> method on every h264 frame.

```python
import depthai as dai
import robothub as rh

frame_buffer: rh.FrameBuffer = FrameBuffer(maxlen=rh.CONFIGURATION["fps"] * 60 * 2)

def process_h264(h264_frame: dai.ImgFrame) -> None:
    frame_buffer.add_frame(packet=h264_frame)
    if important_condition() is True:
        frame_buffer.save_video_event(before_seconds=60,
                                      after_seconds=60,
                                      title="Interesting video",
                                      fps=rh.CONFIGURATION["fps"],
                                      frame_width=1920,
                                      frame_height=1080)
```

### robothub.frame_buffer.FrameBuffer

Kind: Class

#### __init__(self, maxlen: int = None)

Kind: Method

A buffer for storing frames.

:param maxlen: The maximum number of frames to store in the buffer. If None, the buffer will be unbounded.

#### save_video_event(self, before_seconds: int, after_seconds: int, title: str, fps: int, frame_width: int, frame_height: int,
on_complete: Optional [ Callable ] = None, delete_after_complete: bool = False) -> threading.Thread: threading.Thread

Kind: Method

Saves a video event to the frame buffer, then calls `on_complete` when the video is ready.
When the video is ready, the `on_complete` function will be called with the path to the video file.
Note: When app is stopped, it is not guaranteed that the video will be saved.

:param before_seconds: Number of seconds to save before the event occurred.
:param after_seconds: Number of seconds to save after the event occurred.
:param title: Title of the video event.
:param fps: The FPS of the video.
:param frame_width: Video frame width.
:param frame_height: Video frame height.
:param on_complete: Callback function to call when the video is ready. Path to the video file will be passed as the first
argument.
:param delete_after_complete: If True, delete the video file after the callback function is called. Default: False.
:return: The 'threading.Thread' where the video is processed.

#### add_frame(self, packet: Union [ FramePacket , dai.ImgFrame ])

Kind: Method

Default callback for the frame buffer. It will append the packet to the buffer and put it in all temporary queues.

#### maxlen

Kind: Property
