I'm trying to get the first frame of a Streaming video via the URL. getFrameAtTime always seems to return null with no Exception.
@Override
protected Bitmap doInBackground(String... strings) {
String url = strings[0];
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); //Is actually available in Api levels < 10 all the way to 5
try {
retriever.setDataSource(url, new HashMap<String, String>());
return retriever.getFrameAtTime(1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
Log.e(TAG, "problem retrieving frame " + ex);
} catch (RuntimeException ex) {
ex.printStackTrace();
Log.e(TAG, "problem retrieving frame " + ex);
} finally {
try {
retriever.release();
} catch (RuntimeException ex) {
Log.e(TAG, "problem retrieving frame " + ex);
}
}
return null;
}
Have you tried FFmpegMediaMetadataRetriever?: