Metadata Generation for Videos
In this tutorial we will cover metadata generation for videos.
The goal is to generate a table with one row for each video and one column for each tag indicating if that tag is present or not in the video. Coactive already provides the scores for different dynamic tags at the keyframe level in the table so generating metadata is basically an aggregation of those scores at the video level.
It is possible to create metadata from Dynamic Tags and Concepts.
Metadata Generation using Dynamic Tags
The SQL query below generates metadata for videos based on visual dynamic tag scores. It follows the rule to tag every video with K or more keyframes with dynamic tag scores above the percentile P.
The query reads the keyframe-level view dt_<dynamic_tag_group_name>_visual, which has no video ID, so it joins to coactive_table on coactive_image_id to get coactive_video_id. For the columns in each dynamic tag view, see Dynamic Tag Tables.
Explanation
- CTE (keyframe_scores): Join each keyframe’s tag scores to its video ID.
- CTE (dt_count): Count the total number of keyframes for each dynamic tag.
- CTE (percentile_table): Normalize the dynamic tags scores so that they are between 0 and 1 using the scores distribution for each tag.
- CTE (hit_table): Check which keyframes are above a desired threshold P (between 0 and 1). A P of 0.01 means that only the top 1% keyframes of a dynamic tag will be tagged.
- CTE (join_table): Join the table with the tags back to the original keyframe table.
- Final Query: Aggregate the table at the video level tagging all the videos with K or more tagged keyframes.
The same approach works for transcript-level tags: use dt_<dynamic_tag_group_name>_transcript joined to coactive_table_transcription on coactive_transcript_id = id. For the view’s columns, see Dynamic Tag Tables.
Metadata Generation using Concepts
The same exercise can also be done with concepts following the SQL query below. It follows the rule to tag videos with K or more keyframes with the concept score above a threshold T.
Explanation
Define a threshold T to tag every keyframe with a concept score above it. The interpretation is that we are tagging every keyframe with a probability T or bigger of belonging to the concept;
- CTE (video_level_tab): count how many keyframes were tagged in a video.
- Final Query: Tag the videos with K or more tagged keyframes
