[FREE] [BETA] Extract image frame from video

Introduction


Hi! This is a simple extension to extract a frame from a video :hugs: Hope you like it :slight_smile: This extension is still under development so there might be a bunch of bugs :sweat_smile:
(more detailed documentation will be made)

This extension is suggested by @eps_prieur:

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

Documentation


Block Description
Error Raises when any errors occurred
GotImage Raises when an image is extracted by the async method
ImageCreated Raises when images are deleted by the method DeletAllCreatedImagesAsync.
GetImageViaPath Get an image of a video with a given time. Use -1 if you don’t need an option.
video that can be accepted: Absolute path, File URL path, Uri path and URL (direct media link).
If you are using png, you can ignore the quality. Else if you use JPEG, you have to define one. Possible range: 0-100 (lowest to highest)
Return an external path, or “Error” if any error occurred.
GetImageViaPathAsync Does the same as GetImageViaPath but run in an async way.
CreatedImages Return a list of ALL created Images (except the deleted one).
DeleteAllCreatedImages Delete 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.
DeletAllCreatedImagesAsync Does the same as GetImageViaPath but run in an async way.
DeleteAllOnDestroy True if you want to delete all on destroy, otherwise false.
SavePath Defining the absolute path to store the created image. (default is the primary shared/external storage directory)
SaveType Define the type of the image. Acceptable inputs are: png, jpeg (not case-sensitive)
Closest, ClosestSync, NextSync, PreviousSync The constant of options

For options, here is 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

Change Log


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 images

Download


List of version(s)

Beta 1.2 (23.1 KB)
Beta 1.1 (22.1 KB)
Beta 1.0 (18.4 KB)

Reminder


  • 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 implemented the class of QUtil
  • People who helped me during the development: @Mohamed_Tamer

Demo project + app

ExtractImageFromVideo.aia (58.7 KB)
ExtractImageFromVideo.apk (5.4 MB)

25 Likes

Great job :partying_face::+1:

Nice Work I Have Waiting For It

I Have A Question Why You Are Using Two Java File QUtil.java What Is Benefits Of It Why We Cant Put these Code In One File ?

1 Like

That is for part of the code for determining the videoPath you’ve given. And there’s nothing bad to use two file

2 Likes

Very good !
Thank you so much.
Personally, I did not find a bug, the handling is
easy.

I left the options at -1 because I don’t know what the option is and how to rate it.

But once again a big, very big thank you!

1 Like

Thanks a lot!

Nice Extension :grin::+1:

1 Like

OK !
I really love this extension for my project!

Do you think that it would be possible to be able to define the folder in which the images are stored? (by default, at the root)

I also noticed that some created images are renamed with a “-” in front of them. It doesn’t necessarily interfere with opening it but it’s surprising -641997442.png.
By the way, what does this generated figure correspond to: 641997442
Thank you again for the time spent reading me and making this extension.
Ced

1 Like

The file name is a random number for not overwriting other files.

I will definitely try it, thanks for suggesting!

Beta 1.1 is out!

1 Like

Great work ! :+1:

1 Like

Hello and thank you for the update

How to define and use Set. […]. SavePath?

I tried to define a new folder when initializing the screen but I got this message:
invoke:
no method named `SavePath 'in class com.watermelonice.GetImageFromVideo.GetImageFromVideo

Ced

This error means the extension hasn’t been upgraded (because this method doesn’t exist in previous version). Reset companion and also delete app data.

2 Likes

Updated to Beta 1.2 :wink:

Gonna be a bomb, unfortunately i have to give an update to one of my extension so wont be able to test it.

Waiting for the final release after beta testing !!!

Best of luck and great job !!!

1 Like

Can this be used to generate thumbnails?

Can you generate images, frame by frame from a video?

1 Like

how it works

‎‎‎‎‎‎‎‎‎‎‎

can he works with for each block