Reputation: 4545
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 ?
Upvotes: 5
Views: 4354
Reputation: 1105
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
Upvotes: 6
Reputation: 1785
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:)
Upvotes: 1
Reputation: 814
In some specific scenarios, 1 - if HTML5 video tag contains poster in it, you can parse the page to find its value. 2 - If by any chance site is youtube , the answer is here >>How do I get a YouTube video thumbnail from the YouTube API?
Upvotes: -1