3

I want to show video thumbnail as GIF from video URL like TikTok - including musical.ly app.

See below video for getting more details

I have used this to get first 10-15 video frames to generate GIF. but it's not working.

 MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();

  mediaMetadataRetriever .setDataSource(url, new HashMap<String, String>());
  Bitmap bmFrame = mediaMetadataRetriever.getFrameAtTime(1000); //unit in microsecond
  capturedImageView.setImageBitmap(bmFrame);
Pritam
  • 339
  • 3
  • 23
Akash Patel
  • 3,091
  • 3
  • 15
  • 23
  • 1
    https://stackoverflow.com/questions/44943575/how-to-create-thumbnail-of-video-url-form-server/44943830#44943830 – AskNilesh Aug 29 '18 at 05:53
  • 1
    Check this answer and link : https://stackoverflow.com/a/50942061/6238866 – Mayur Patel Aug 29 '18 at 06:02
  • @NiteshRathod Tried that but getting below error. java.lang.RuntimeException: setDataSource failed: status = 0x80000000 at android.media.MediaMetadataRetriever._setDataSource(Native Method) at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:102) – Akash Patel Aug 29 '18 at 06:04
  • @MayurPatel It is for normal video thumb. but i want thumb as GIF format. like this https://drive.google.com/open?id=1aFRq0FoPITEyZJr6p8AAjDdHuXULcgVc – Akash Patel Aug 29 '18 at 06:08
  • Just use this code like . String bitmapPath = SaveImage(ThumbnailUtils.createVideoThumbnail(uri.getPath(), MediaStore.Video.Thumbnails.FULL_SCREEN_KIND)); – Ravindra Kushwaha Aug 29 '18 at 06:10
  • String SaveImage(Bitmap bitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + FileUtils.mediaPath); bitmap = "MY_IMAGE" + System.currentTimeMillis() + ".jpg"; File file = new File(myDir, bitmap); if (file.exists()) file.delete(){ FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 70, out); out.flush(); out.close(); bitmap = String.valueOf(file); return bitmap; } – Ravindra Kushwaha Aug 29 '18 at 06:11
  • @AkashPatel do you means you need to GIF image for video view? – Mayur Patel Aug 29 '18 at 07:27
  • @MayurPatel I want to show GIF as video thumbnail until video is ready to play. and I will show it on ImageView. – Akash Patel Aug 30 '18 at 05:28
  • @AkashPatel did you got any solution for this thread? I also need to implement this feature. if you know please update the answer. Thanks. – Rao Arsalan Oct 15 '20 at 13:07
  • @RaoArsalan Not yet, I'm generating GIF from mobile and storing it on server. – Akash Patel Oct 16 '20 at 13:24

0 Answers0