File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,22 @@ This will create tables called `cool_videos` and `cool_frames`.
3030Using 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
3737An example:
3838
3939```
4040import 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
4650video_to_sqlite.main('my_database.db', 'cool_video.mp4', 'cool_', my_callback)
4751```
You can’t perform that action at this time.
0 commit comments