Skip to content

Commit

Permalink
Add Video formats (video_frames and video_keyframes) (#872)
Browse files Browse the repository at this point in the history
* initialization

* add examples

* refine descriptions of video format

* update base url

* update doc for video format

* correct typo

---------

Co-authored-by: wonjuleee <wonju@intel.com>
  • Loading branch information
wonjuleee and wonjuleee authored Mar 22, 2023
1 parent f75b68e commit ef83f54
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions site/content/en/docs/formats/video.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: 'Video'
linkTitle: 'Video'
description: ''
---

## Format specification
There are many kinds of video extensions as listed up
[here](https://github.com/openvinotoolkit/datumaro/blob/develop/datumaro/plugins/data_formats/video.py).

Datumaro can import a video into video frames by adjusting the start frame, end frame,
and step size. Furthermore, with a `video_keyframes` format, Datumaro can extract
keyframes by comparing zero-mean normalized cross correlation (ZNCC) metric between
successive frames as following [here](https://www.sciencedirect.com/science/article/pii/S1047320312000223).
Plus, Datumaro provides the options for choosing image extension and name patterns
for efficient data management from multiple videos.

## Import video

A Datumaro project with a video frames can be created
in the following way:

```
datum create
datum import -f video_frames <path_to_video>
```

Load video through the Python API:

```python
import datumaro as dm

dataset = dm.Dataset.import_from('<path_to_video>', format='video_frames')
```

Datumaro has few import options for `video_frames` format, to apply them
use the `--` after the main command argument.

`video_frames` import options:
- `--subset` (string) - The name of the subset for the produced
dataset items (default: none)
- `-p, --name-pattern` (string) - Name pattern for the produced
images (default: `%06d`)
- `-s, --step` (integer) - Frame step (default: 1)
- `-b, --start-frame` (integer) - Starting frame (default: 0)
- `-e, --end-frame` (integer) - Finishing frame (default: none)
- `-h, --help` - Print the help message and exit

Usage:

``` console
datum import -f video_frames [-h] [-n NAME] [-r RPATH] [-p PROJECT_DIR]
[--no-check] [-s STEP] [-b START_FRAME] [-e END_FRAME] url ...
```

Example: import a video into frames, use each 30th frame:
```console
datum import -f video_frames video.mp4 -o video-frames --step 30
```

Example: import a video into frames, save as 'frame_xxxxxx.png' files:
```console
datum import -f video_frames video.mp4 -o video-frames --image-ext=.png --name-pattern='frame_%%06d'
```

Example: import a video into keyframes:
```console
datum import -f video_keyframes video.mp4 -o video-frames
```

0 comments on commit ef83f54

Please sign in to comment.