Hossin Asaadi
Hossin Asaadi

Reputation: 405

how get frame from video url and show in ImageView

I use glide to get frame from video url but glide for get frame, download the whole video and it takes time.

        RequestOptions myOptions = new RequestOptions()
            .fitCenter()
            .centerCrop().circleCrop()
            .placeholder(R.drawable.loading_circle);

       Glide.with(context)
            .asBitmap()
            .apply(myOptions)
            .load(Link)
            .into(image);

How can I get the last frame from the video?

Upvotes: 2

Views: 8150

Answers (2)

Omar Dhanish
Omar Dhanish

Reputation: 875

you can use MediaMetadataRetriever for doing that , you can also use url , code sample from here ,

.....

String url = "yoururl";

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ImageView capturedImageView = (ImageView)findViewById(R.id.capturedimage);

  MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();

  mediaMetadataRetriever .setDataSource(url, new HashMap<String, String>());
  Bitmap bmFrame = mediaMetadataRetriever.getFrameAtTime(1000); //unit in microsecond
  capturedImageView.setImageBitmap(bmFrame);
 }

Upvotes: 5

Umar Hussain
Umar Hussain

Reputation: 3527

See if this helps you need this api to first fetch the frame separately and then use the glide How to get video thumbnail (frame) from live video url

Upvotes: 0

Related Questions