Background
The company recently requested to give me the responsibility of the app plus video recording and publishing features, I simply completed the basic recording and video compression function, and later found that the publishing interface needs to upload video, online search for information, here to organize a bit.
Code implementation
/** * Get the video file * * @param path of the path video file * @return Bitmap returns the obtained Bitmap */ Public StaticBitmapGetvideothumb(String Path) {Mediametadataretriever Media =NewMediametadataretriever (); Media.setdatasource (path);returnMedia.getframeattime (); }/** * Get the video file thumbnail api>=8 (2.2) * * @param path Video file paths * @param Kind thumbnail resolution: Mini_ki ND, Micro_kind, Full_screen_kind * @return Bitmap returns the acquired Bitmap */ Public StaticBitmapGETVIDEOTHUMB2(String Path,intKind) {returnThumbnailutils.createvideothumbnail (path, kind); } Public StaticBitmapGETVIDEOTHUMB2(String Path) {returnGETVIDEOTHUMB2 (path, MediaStore.Video.Thumbnails.FULL_SCREEN_KIND); }
The above is a way to get video files and thumbnails, and you may also need to Bitmap
save them as files:
/** * Bitmap saved as file * * @param bitmap input bitmap * @param name output file ' s Nam E * @return String output file ' s path * / Public StaticStringBitmap2file(Bitmap Bitmap, String name) {File F =NewFile (environment.getexternalstoragedirectory () + name +". jpg");if(F.exists ()) F.delete (); FileOutputStream FOut =NULL;Try{FOut =NewFileOutputStream (f); Bitmap.compress (Bitmap.CompressFormat.JPEG, -, FOut); Fout.flush (); Fout.close (); }Catch(IOException e) {return NULL; }returnF.getabsolutepath (); }
References and summaries
The above is their own collection and collation of a bit of information, there is no multi-faceted comparison and deep-seated analysis (API version restrictions, etc.), the use of any questions welcome message.
Android get pictures and video thumbnails on your phone thumbnails
Android must know-get thumbnail images of video files
Gets the local video file's
Android must know-get thumbnail images of video files