Android must know-get screenshots of video files, thumbnail images

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.