Reputation: 405
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
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
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