getFrameAtTime() returns Same Frame
I ran into the same problem but I could not find a solution using the MediaMetadataRetriever.
However, I did using this: https://github.com/wseemann/FFmpegMediaMetadataRetriever
Hope it helps.
NullPointerException when threading MediaMetadataRetriever [Android]
I have been able to fix the bug, but with lackluster results. The only way I have found to stop the exception from appearing is by putting a synchronize block around the MediaMetadataRetriever getFrameAtTime() function call. The new getVideoFrame method is below.
private Bitmap getVideoFrame(Uri uri, long timeInUSeconds) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(this, uri);
synchronize (this) {
Bitmap temp = retriever.getFrameAtTime(timeInUSeconds, MediaMetadataRetriever.OPTION_CLOSEST);
}
retriever.release();
return temp;
}
Sadly, as this fixes the bug, the speed concern is not aleviated, as getting the frame still takes a substantial amount of time, far more so than actually processing the frames. Nevertheless, the pr
Saving first and last frame of a video as an image on Android
You may want to take a look at the MediaMetadataRetriever
class.
More specifically its getFrameAtTime(long)
method.
To get the time of the last frame use getDuration()
, which will return the duration of the video.
Note: This is available from API level 10!
Related Topics
Android:Change Button Text and Background Color
Clear Application Cache on Exit in Android
Add an Image from Url into Custom Infowindow Google Maps V2
Android: Changing Nfc Settings (On/Off) Programmatically
Can Gradientcolor Be Used to Define a Gradient for a Fill or Stroke Entirely in Xml
Android Button Background Color
Android Studio 3.0 Compile Issue (Cannot Choose Between Configurations)
R.Java Disappears After Project Clean
How Does One Implement Drag and Drop for Android Marker
Hax Kernel Module Is Not Installed
Communication Between Broadcastreceiver and Activity - Android
How to Create Ripple Effect for Pre-Lollipop
How to Change Action Bar Actions Dynamically