Download first frame of video android programmatic

2019-04-13 07:08发布

问题:

I want to download a single frame of a video file from a server from my android application. I do not wat to download the full video at front. Use that frame as a thumbnail to display to the user, so that if choosen by user it can be downloaded.

回答1:

ffmpeg can create a thumbnail from a video stream using this command:

ffmpeg -itsoffset -4  -i http://somevideosite/test.avi -vcodec mjpeg -vframes 1\
       -an -f rawvideo -s 320x240 thumb.jpg

To get ffmpeg into android seems doable.



回答2:

It will be easier if your server provided thumbnails for each video like youtube/dailymotion does. You could create this thumbnail when video is added to the server.

Ex: http://img.youtube.com/vi/<VIDEO_ID>/<1,2,3>.jpg