video_thumbnail icon indicating copy to clipboard operation
video_thumbnail copied to clipboard

Library only exports key frames on Android

Open andreasmpet opened this issue 2 years ago • 1 comments

Hi!

I am trying to use this library to create a video timeline view with thumbnails at arbitrary millisecond intervals.

I did, however, find that you were using OPTION_CLOSEST_SYNC in the following code line:

bitmap = retriever.getScaledFrameAtTime(timeMs * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC, targetW, targetH);

This means that you will only fetch the nearest keyframe. Sure, this is super fast, but I think it should be configurable to ask for interpolated frames by using OPTION_CLOSEST instead.

I will alleviate this issue personally by forking the library, but maybe you would be so kind as to make it configurable.

I understand that making this configurable also might not make sense in a cross platform world where the iOS version might not be behaving the same way.

If I were you I would make sure iOS and android at least acted in the same way. There is no hint that copyCGImageAtTime in the iOS implementation only fetches key frames.

andreasmpet avatar Nov 12 '21 15:11 andreasmpet

Now it makes sense why it ends up returning the same thumbnail when providing small step difference, like 300ms

emvaized avatar Dec 19 '21 18:12 emvaized