1. Preface
This article discusses capturing the video at a certain point in time, rather than the screen.
If you want to get the screen directly (power key + volume)
2. Get the video2.1Mediametadataretriever
Mediametadataretriever from the name of the video can be obtained metadata information, in addition to get the video, where the thumbnail of the extracted video is implemented by this function.
2.2 How to use
The frame image of the video is obtained using the mediametadatretriever.getframeattime method.
public Bitmap Getframeattime (long Timeus)
public Bitmap Getframeattime (long timeus, int option)
It is important to note that:
The units of the time point are microseconds, the units of ordinary time are milliseconds;
Option:
Option_closest: Gets the most recent frame image from Timeus.
The frame obtained by this function is sync frame, because there is not necessarily a sync frame at this point in the Timeus, so there is a certain error.
There are 3 scenarios when getting sync frame:
(1) There is exactly one sync Frame at the Timeus place
(2) Get timeus before a sync Frame
(3) Get timeus after a sync Fram
Option_previous_sync: (1) or (2)
OPTION_NEXT_SYNC
: (1) or (3)
Option_closest_sync: Get a SYNC Frame closest to Timeus
Mediametadataretriever retriever = new Mediametadataretriever (); try {retriever.setdatasource (Mfilepath); Bitmap Bitmap = Retriever.getframeattime (micurpos*1000); String path = environment.getexternalstoragedirectory () + File.separator + environment.director Y_DCIM + "/camera"; Path + = Tools.getdisplayname (Mfilepath) + "_" + tools.inttotimestring (Micurpos) + "_" + ". png"; Tools.savebitmap (bitmap, path); Sendbroadcast (New Intent (Intent.action_media_scanner_scan_file, Uri.fromfile (new FILE)); } catch (IllegalArgumentException e) {e.printstacktrace (); VIDEOLOGGER.E (TAG, "Mediametadataretriever.setdatasource Failed:" + Mfilepath); Showtoast (Mresources.getstring (r.string.info_screen_shot_failed), 0); }
Android Video