-2

I know this is not the right platform for asking this question and i will definitely get huge no. of down-votes for this, but i don't have any other choice. If anyone just give me a small solution that will be great.

Till now in my android app, I am able to choose video from my gallery and successfully uploaded it to my server. Now i want that when i choose the video then its thumbnail should be generated and i should be able to upload that image along with the video in my server. This is the point where i am stucked currently, need any useful link or tutorial for the same, searched google but finally here with a hope.

Nayan Das
  • 75
  • 7
  • 'I know this is not the right platform for asking this question, but i don't have any other choice' - have you considered doing some more research work, trying some code, you know, stuff that you don't already know is wrong? – Martin James Jan 01 '18 at 20:47

1 Answers1

2

You can create VideoThumbnail from sdcard path like this.

Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);

Using ThumbnailUtils, you can create thumbnail of two types.

MediaStore.Images.Thumbnails.MICRO_KIND type will generate thumbnail of size 96 x 96. MediaStore.Images.Thumbnails.MINI_KIND type will generate thumbnail of size 512 x 384.

After creating the thumbnail you can upload the bitmap created directly to server giving the bitmap's reference that has been genereated.

Saurav Prakash
  • 588
  • 1
  • 5
  • 26
  • can i directly send "thumb" object to my server as i send normal image path or need to send the path where the thumbnail is generated – Nayan Das Dec 25 '17 at 12:02
  • you can directly send the thumb object to server. [ Please accept this answer ] – Saurav Prakash Dec 25 '17 at 12:10
  • hi not getting the idea how to pass the bitmap object using http request to my php server – Nayan Das Dec 25 '17 at 12:38
  • 1
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); photo.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); Then send this encodedImage as a String and in your server you will need to decode it in order to get the image itself. – Saurav Prakash Dec 25 '17 at 12:40
  • 1 last help, how to decode the image in php, thnx – Nayan Das Dec 25 '17 at 12:48
  • 1
    https://stackoverflow.com/questions/15153776/convert-base64-string-to-an-image-file – Saurav Prakash Dec 25 '17 at 12:49