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 ?
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
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:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With