How to get Thumbnail online video without downloading in Android

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

Is it possible?

Is this possible with a universal image downloader?

+5
source share
3 answers

It is not possible to get a video thumbnail on the Internet without fully downloading the video using the built-in API for Android, but using ffmpeg

We can extract the thumbnail from the downloaded video using the method below.

ThumbnailUtils.createVideoThumbnail (String filePath, int kind) 

Where

filePath video file path

kind can be MINI_KIND or MICRO_KIND

Return value

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

I created a demo application for you. Please find the path to the android project which is uploaded to github AndroidFFmpeg

Run the command below to extract the first frame from the URL of the online video:

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] 

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 create a thumbnail on the SDCard with a resolution of 320x240 named thumb.jpg

+6
source

I believe that there is no easy way to create a thumbnail without actually downloading the video locally.

So, if your question is: β€œCan I get a sketch without downloading the full video?”, I would say ... no.

Otherwise, as soon as you upload the video locally, I think you can use ThumbnailUtils.createVideoThumbnail(...) perfectly, specifying the path to the downloaded file.

and another option to create a thumb video:

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

enjoy the code :)

+1
source

In some specific scenarios, 1 - if the HTML5 tag contains a poster in it, you can analyze the page to find its meaning. 2 - If for some reason the site is youtube, the answer is here β†’ How to get a thumbnail of a YouTube video using the YouTube API?

-1
source

All Articles