Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Online Video Thumbnail without download in android

I need to get the thumbnail of an online video file without downloading the file.

Is it possible ?

Is it possible with Universal Image Loader ?

like image 904
Hossein Kurd Avatar asked Aug 16 '15 13:08

Hossein Kurd


2 Answers

There is no way to get online video thumbnail without downloading of video completely using in-built android API but using ffmpeg

We can extract thumbnail from downloaded video using below method.

ThumbnailUtils.createVideoThumbnail (String filePath, int kind)

where

filePath the path of video file

kind could be MINI_KIND or MICRO_KIND

Return value

May return null if the video is corrupt or the format is not supported.

I have created demo application for you. Please find path of android project which is uploaded on github AndroidFFmpeg

Execute below command to extract first frame from online video url:

Syntax:

-itsoffset -4 -i [Url of online video] -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 [Path of image where thumbnail to be stored]

For Example:

-itsoffset -4 -i http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4 -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 /sdcard/thumb.jpg

This will generate thumbnail image on SDCard with resolution 320x240 with name thumb.jpg

like image 155
Durgesh Patel Avatar answered Nov 14 '22 22:11

Durgesh Patel


I suppose there is no easy way to build the thumbnail without actually downloading the video locally.

So if your question is 'Can I get a thumbnail without having to download the full video?', I'd say...no.

Otherwise, once you have downloaded the video locally, then I guess you can perfectly use ThumbnailUtils.createVideoThumbnail(...)by giving the path to the downloaded file.

and other option for creating video thumb:

Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND);

enjoy your code:)

like image 37
John smith Avatar answered Nov 15 '22 00:11

John smith