Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for iframe based video sampling #590

Closed

Conversation

dungnmaster
Copy link
Collaborator

@dungnmaster dungnmaster commented Feb 17, 2023

Now videos can be sampled for IFRAMES using 'iframe' keyword with SAMPLE clause
e.g.
==> SELECT id FROM MyVideo SAMPLE IFRAMES 7 ORDER BY id;
==> SELECT id FROM MyVideo SAMPLE IFRAMES ; # this uses default sampling rate of 1

@dungnmaster dungnmaster marked this pull request as draft February 17, 2023 06:16
@dungnmaster dungnmaster changed the title feat: Adding support for iframe based video sampling feat: Add support for iframe based video sampling Feb 17, 2023
@dungnmaster dungnmaster marked this pull request as ready for review February 18, 2023 16:55
@@ -122,6 +122,8 @@ subquery_table_source_item: (select_statement | LR_BRACKET select_statement RR_B

sample_clause: SAMPLE decimal_literal

sample_clause_with_type: SAMPLE decimal_literal string_literal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also support SAMPLE IFRAMES. I feel this is an important usecase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default the sampling rate to 1

for frame_id in range(begin, end + 1, self._sampling_rate):
frame = video[frame_id]
if frame is not None:
yield {"id": frame_id, "data": frame}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add seconds here

frame = video[frame_id]
idx += self._sampling_rate
if frame is not None:
yield {"id": frame_id, "data": frame}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add seconds here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add it in the opencv_reader

)
batches = list(video_loader.read())
for batch in batches:
print(batch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this print

def tearDown(self):
file_remove("dummy.avi")

def test_should_sample_every_k_frame(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, add a test case for IFrames. Thanks!

can be converted to ranges. Defaults to None.
sampling_rate (int, optional): Set if the caller wants one frame
every `sampling_rate` number of frames. For example, if `sampling_rate = 10`, it returns every 10th frame. If both `predicate` and `sampling_rate` are specified, `sampling_rate` is given precedence.
sampling_type (str, optional): Set as 'iframe' if caller want to sample on top on iframes only.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a few simple examples for explainability.
Rest looks good!

@gaurav274
Copy link
Member

#616

@gaurav274 gaurav274 closed this Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants