DALI icon indicating copy to clipboard operation
DALI copied to clipboard

Frame extraction by timestamp

Open jadechoghari opened this issue 9 months ago • 4 comments

Describe the question.

Hello,

is it possible to extract the exact frame based on a specified timestamp? for example if i pass [2.7600, 2.7800, 2.8000, 2.8200, 2.8400] I would get 5 frames corresponding to these timestamps returned (one video).

cc @JanuszL

Thank you 🤗!

Check for duplicates

  • [x] I have searched the open bugs/issues and have found no duplicates for this bug report

jadechoghari avatar Mar 25 '25 14:03 jadechoghari

Hell @jadechoghari

thanks for the question. I think you are looking for enable_timestamps argument of our video reader

It works together with file_list argument. You can create a list and pass desired frames as list items. Is that enough for your use case?

awolant avatar Mar 25 '25 14:03 awolant

Hey! I tried but it seems you can only pass a range say from 5.1 to 5.2 sec and it will sample from this range. any way to get exact timestamp?

Take torchcodec for example :

# initialize video decoder
decoder = VideoDecoder(video_path, device=device, seek_mode="approximate")
# ...
frames_batch = decoder.get_frames_at(indices=frame_indices)

jadechoghari avatar Mar 25 '25 14:03 jadechoghari

Sure, I understand now. I am afraid that currently there is now way to get arbitrary frames by timestamp. I will mark this issue as a possible enhancement to the new video reader that we actively improve at the moment.

Do I understand correctly that API matching torchcodec would be something you are looking for?

awolant avatar Mar 25 '25 14:03 awolant

yes exactly! it will be used in robotics!

jadechoghari avatar Mar 25 '25 14:03 jadechoghari