From b08f7629dd61daf13a1797e39be75dd3a3a9cb94 Mon Sep 17 00:00:00 2001 From: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:59:10 +0100 Subject: [PATCH] Small addition to video docs (#7263) minor video docs --- docs/source/video_load.mdx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/source/video_load.mdx b/docs/source/video_load.mdx index b30f0f4aeff..3744995b6ed 100644 --- a/docs/source/video_load.mdx +++ b/docs/source/video_load.mdx @@ -26,12 +26,29 @@ When you load an video dataset and call the video column, the videos are decoded -Index into an video dataset using the row index first and then the `video` column - `dataset[0]["video"]` - to avoid decoding and resampling all the video objects in the dataset. Otherwise, this can be a slow and time-consuming process if you have a large dataset. +Index into an video dataset using the row index first and then the `video` column - `dataset[0]["video"]` - to avoid reading all the video objects in the dataset. Otherwise, this can be a slow and time-consuming process if you have a large dataset. For a guide on how to load any type of dataset, take a look at the general loading guide. +## Read frames + +Access frames directly from a video using the `VideoReader`: + +```python +>>> dataset[0]["video"][0].shape # first frame +(240, 320, 3) +``` + +To get multiple frames at once, use `get_batch`. This is the efficient way to obtain a long list of frames: + +```python +>>> frames = dataset[0]["video"].get_batch([1, 3, 5, 7, 9]) +>>> frames.shape +(5, 240, 320, 3) +``` + ## Local files You can load a dataset from the video path. Use the [`~Dataset.cast_column`] function to accept a column of video file paths, and decode it into a `decord` video with the [`Video`] feature: