justsoft / video_thumbnail

This plugin generates thumbnail from video file or URL. It returns image in memory or writes into a file. It offers rich options to control the image format, resolution and quality. Supports iOS and Android.
MIT License
183 stars 238 forks source link

Library only exports key frames on Android #90

Open andreasmpet opened 2 years ago

andreasmpet commented 2 years ago

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.

emvaized commented 2 years ago

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