Skip to content

Commit 62493dc

Browse files
committed
update README to match v0.0.2 API
1 parent 72352a0 commit 62493dc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ This will create tables called `cool_videos` and `cool_frames`.
3030
Using the library programatically allows extra columns to be added to the database via a callback. Specify the
3131
`callback` argument to `cli.main()`.
3232

33-
The function will be called once per frame in the video. It should accept a numpy ndarray as the single argument, and
34-
return a dict. The dict's keys will be added as columns to the DB, and values will be the corresponding values for that
35-
row.
33+
The function will be called once per frame in the video. It should accept a numpy ndarray of the frame in question,
34+
and a dict containing metadata for the frame. The callback should return a dict. The dict's keys will be added as
35+
columns to the DB, and values will be the corresponding values for that row.
3636

3737
An example:
3838

3939
```
4040
import video_to_sqlite
4141
42-
def my_callback(frame):
42+
def my_callback(frame, metadata):
4343
has_a_cat_in_it = ai_cat_image_detector(frame)
44-
return {'cat': has_a_cat_in_it}
44+
45+
if metadata['pict_type'] == 'I': # is this frame a keyframe?
46+
brightness = get_average_brightness(frame)
47+
48+
return {'cat': has_a_cat_in_it, 'brightness': brightness}
4549
4650
video_to_sqlite.main('my_database.db', 'cool_video.mp4', 'cool_', my_callback)
4751
```

0 commit comments

Comments
 (0)