Android Video screenshot

Source: Internet
Author: User

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

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.