Question: I am getting black screen not the video content please help me.

My code:

```
 private Bitmap takeScreenshot() {
    relate.setDrawingCacheEnabled(true);
    relate.buildDrawingCache();
    return relate.getDrawingCache();
}

private void saveBitmap(Bitmap bitmap) {
    //  File imagePath = new File(Environment.getExternalStorageDirectory()     + "/screenshot.png");

    FileOutputStream fos;
    // String path ="data/data/com.focusmedica.eyeactivity/files/Images" +    filename;

    try {
        fos =new FileOutputStream(path);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
        fos.flush();
        fos.close();
        sentmail(path);
    } catch (FileNotFoundException e) {
        Log.e("GREC", e.getMessage(), e);
    } catch (IOException e) {
        Log.e("GREC", e.getMessage(), e);
    }
}

```

i am using `canvas` for drawing something on `videoview`.and only i get black screen.
 my `videoview` is inside in `relative layout`.
 Thanks in Advance.....

Answer: 
From the [android](https://developer.android.com/reference/android/media/MediaMetadataRetriever.html) here you can get snapshot or frame of video view. 

You can try this code to get the videoview frame.

```
    public static Bitmap createVideoThumbnail(Context context, Uri uri, int i)
    {
     MediaMetadataRetriever mediametadataretriever = new MediaMetadataRetriever();

try {
    mediametadataretriever.setDataSource(context, uri);
    Bitmap bitmap = mediametadataretriever.getFrameAtTime(-1L);
    if(null != bitmap)
    {
        int j = getThumbnailSize(context, i);
        return ThumbnailUtils.extractThumbnail(bitmap, j, j, 2);
    }
    return bitmap;
} catch (Throwable t) {
    // TODO log
    return null;
} finally {
    try
    {
        mediametadataretriever.release();
    }
    catch(RuntimeException e) { }
    }
}

```

you can make use of this method according to your need.
I have an alternative solution to replace the `getFrameAt` method of Android `MediaMetadataRetriever`. **AV\_FrameCapture** uses `MediaCodec` to decode the video frame and use `OpenGL` to convert the video frame as RGB Bitmap. As Android `MediaMetadataRetriever` does not guarantee to return a result when calling `getFrameAtTime`, this `AV_FrameCapture` can be used to extract a frame of video with **accuracy**.

<https://stackoverflow.com/a/60633395/6676310>