This error occurred when I upgraded the SDK from 23 to 26 in my AndroidManifest.xml and gradle build. Thought it might be related to the Uri.fromFile() error that is caused by using external apps thru Intent (passing a file to the Camera for example) but the source in the SDK does not seem to be doing that.
The call looks like this and the path is correct:
Bitmap captured = ThumbnailUtils.createVideoThumbnail(videoSourcePath,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
I have verified the file exists and that AndroidManifest.xml has the external storage permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Has something changed between SDK 23 and 26 that I am not aware of in regards to capturing the bitmap from an MP4 file?
UPDATE
So the real problem turned out to be the path to the image. Looks like under SDK 26 when you get the data returned from the Intent (in this case a video capture) if you use the following call:
videoSourcePath = data.getData().getPath();
It will no longer return the physical location of the video correctly, but tacks on "external_files" which made the path invalid.
So what was once returned was:
/storage/emulated/0/myapp/mycustomer/newvideofile.mp4
Now is:
/external_files/myapp/mycustomer/newvideofile.mp4
I ended up just using the original source I sent in rather than relying on what the Intent is returning.
You can use Glide to retrieve Thumbnail of Video.
// 1st: Generate image and set to imageview
Glide.with(context).asBitmap()
.load(filePathWithExtension)
.into(imageview);
// 2nd: Get Bitmap from Glide
GlideApp.with(context)
.asBitmap()
.load(filePathWithExtension)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
// You can use **resource**.
imageview.setImageBitmap(resource);
}
});