4

I'm trying to get thumbnail from instagram video by using the following method but it loads very slow. Is there another way I can get thumbnail from video url in efficient manner -

public Bitmap retriveVideoFrameFromVideo(String videoPath)
                throws Throwable
        {
            Bitmap bitmap = null;
            MediaMetadataRetriever mediaMetadataRetriever = null;
            try
            {
                mediaMetadataRetriever = new MediaMetadataRetriever();
                if (Build.VERSION.SDK_INT >= 14)
                    mediaMetadataRetriever.setDataSource(videoPath, new HashMap<String, String>());
                else
                    mediaMetadataRetriever.setDataSource(videoPath);
                //   mediaMetadataRetriever.setDataSource(videoPath);
                bitmap = mediaMetadataRetriever.getFrameAtTime();
            }
            catch (Exception e)
            {
                e.printStackTrace();
                throw new Throwable(
                        "Exception in retriveVideoFrameFromVideo(String videoPath)"
                                + e.getMessage());

            }
            finally
            {
                if (mediaMetadataRetriever != null)
                {
                    mediaMetadataRetriever.release();
                }
            }
            return bitmap;
        }
zek54
  • 415
  • 3
  • 20
  • 1
    Did you find any solution for this? I did this in asyntask but the problem is because of slow response time it sometimes replaces images in my listview. – Shafayat Mamun Sep 20 '16 at 22:45
  • @ Shafayat , can you please share your code to us with this . – Lutaaya Huzaifah Idris Nov 29 '16 at 09:11
  • Possible duplicate of [Is it possible to Generate a thumbnail from a video url in android](https://stackoverflow.com/questions/22954894/is-it-possible-to-generate-a-thumbnail-from-a-video-url-in-android) – Mehdi Dehghani Mar 28 '19 at 05:29

0 Answers0