Hi! This is a simple extension to extract a frame from a video Hope you like it This extension is still under development so there might be a bunch of bugs
(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)
|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:
a hint on how the frame is found. Use
OPTION_PREVIOUS_SYNCif one wants to retrieve a sync frame that has a timestamp earlier than or the same as timeUs. Use
OPTION_NEXT_SYNCif one wants to retrieve a sync frame that has a timestamp later than or the same as timeUs. Use
OPTION_CLOSEST_SYNCif one wants to retrieve a sync frame that has a timestamp closest to or the same as timeUs. Use
OPTION_CLOSESTif 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_CLOSESToften has larger performance overhead compared to the other options if there is no sync frame located at timeUs. Value is either
0or a combination of
Reference: MediaMetadataRetriever | Android Developers
- You can now customize the type (png/jpeg)
Note: Quality of image is added. If you use png, you can ignore it.
- Added path customization
- You can choose not to delete the images created
- You can get a list of created images
- 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