[FREE] [BETA] Extract image frame from video

This is a simple extension to extract a frame from a video. This extension is still under development so there might be a bunch of bugs :/

This extension is suggested by @eps_prieur: https://community.kodular.io/t/extract-an-image-from-a-video-not-thumbnail/91922

Basically, it generates an image and temporarily stored in the external storage. It will be deleted once the application is stopped (OnDestroy)

Documentation

BlockDescription
ErrorRaises when any errors occurred
GotImageRaises when an image is extracted by the async method
ImageCreatedRaises when images are deleted by the method DeletAllCreatedImagesAsync.
GetImageViaPathGet an image of a video with a given time. Use -1 if you don’t need any option.
Path can accept: Absolute path, File URL path, Uri path and URL (direct media link).
Return an external path, or “Error” if any error occurred.
GetImageViaPathAsyncDoes the same as GetImageViaPath but run in an async way.
CreatedImagesReturn a list of ALL created Images (except the deleted one).
DeleteAllCreatedImagesDelete All Created Images. After deletion, the file won’t show up in the CreatedImages list. Files which deletion is failed will stay in the list.
DeletAllCreatedImagesAsyncDoes the same as GetImageViaPath but run in an async way.
DeleteAllOnDestroyTrue if you want to delete all on destroy, otherwise false.
SavePathDefining the absolute path to store the created image. (default is the primary shared/external storage directory)
Closest, ClosestSync, NextSync, PreviousSyncThe constant of options

For options, here is a detailed documentation:

Documentation
a hint on how the frame is found. Use `OPTION_PREVIOUS_SYNC` if one wants to retrieve a sync frame that has a timestamp earlier than or the same as timeUs. Use `OPTION_NEXT_SYNC` if one wants to retrieve a sync frame that has a timestamp later than or the same as timeUs. Use `OPTION_CLOSEST_SYNC` if one wants to retrieve a sync frame that has a timestamp closest to or the same as timeUs. Use `OPTION_CLOSEST` if one wants to retrieve a frame that may or may not be a sync frame but is closest to or the same as timeUs. `OPTION_CLOSEST` often has larger performance overhead compared to the other options if there is no sync frame located at timeUs. Value is either `0` or a combination of `OPTION_PREVIOUS_SYNC` , `OPTION_NEXT_SYNC` , `OPTION_CLOSEST_SYNC` , and `OPTION_CLOSEST`
Reference: [MediaMetadataRetriever | Android Developers](https://developer.android.com/reference/android/media/MediaMetadataRetriever#getFrameAtTime(long,%20int))

Changelog

Beta 1.2

You can now customize the type (png/jpeg) Note: Quality of image is added. If you use png, you can ignore it.

Beta 1.1
  • Added path customization
  • You can choose not to delete the images created
  • You can get a list of created list

Download

Beta 1.2

Older versions

Beta 1.1
Beta 1.0


Demo Project & App

ExtractImageFromVideo.aia
ExtractImageFromVideo.apk

Note

  • android.permission.WRITE_EXTERNAL_STORAGE is required.

Known Issues

  • App will crash if the SavePath is invalid.

Big thanks to

  • Evan W. Patton in AI2 for the implementation of the class of QUtil
  • @Mohamed_Tamer in the Kodular Community

Reference

Kodular Community

Comments