Search code examples
androidservervideo-thumbnails

How to get video thumbnail from server videos?


Guys anyone please help me how to get video thumbnail from server side video?..

I Searched alot in stack but didn't get any useful solution?..

I used FFmpegMediaMetadataRetriever this library.. I faced few errors..


Solution

  • video thumbnail to server

       final File myFile = new File(selectedPath);
        Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(selectedPath, MediaStore.Video.Thumbnails.MINI_KIND);
        String thumbnail = getStringImage(bitmap);
    
    //Server side
      params.put("thumnails",thumbnail);
    
     public String getStringImage(Bitmap bmp){
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            byte[] imageBytes = baos.toByteArray();
            String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
            return encodedImage;
        }