Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Picasso Video Frame RequestHandler
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Request;
import com.squareup.picasso.RequestHandler;
* Loads frames from a video at the specified microsecond. Usage:
* Picasso picasso = new Picasso.Builder(this).addRequestHandler(new VideoFrameRequestHandler()).build();
* picasso.load("videoframe://path/to/video#microseconds
* The offset is in microseconds, so #1000000 = 1 second in.
public class PicassoVideoFrameRequestHandler extends RequestHandler {
public static final String SCHEME = "videoframe";
@Override public boolean canHandleRequest(Request data) {
return SCHEME.equals(data.uri.getScheme());
@Override public Result load(Request data) throws IOException {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
String offsetString = data.uri.getFragment();
long offset = Long.parseLong(offsetString);
Bitmap bitmap = mediaMetadataRetriever.getFrameAtTime(offset);
return new Result(bitmap, Picasso.LoadedFrom.DISK);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment