How to get video thumbnail if i have the rtsp link of the video?

こ雲淡風輕ζ 提交于 2019-12-25 06:13:06

问题


i am developing an android app for my ip camera, and the camera has some specific api commands that it can respond to. the problem i am stuck on is that i want to display a list of videos available on the memory card of the camera. I am getting the file list but i also want to get the thumbnails of those files.

The problem in getting the thumbnail is that i don't have any direct IP address of the video, the camera only provides me two things for accessing the video

1. RTSP URL of the video 
2. Data stream of the video, so that i can download it in my code.

Can someone tell me how can i get the thumbnail of the videos if i have the above mentioned available options?

Note: there's also one API available in the camera for providing the thumbnail of the video, when i send that command it returns me one frame of the video, currently it is sending me the corrupt frame and this method is not working, that's why i am focusing on getting the thumbnail from the other two available options.

any help will be highly appreciated.

Thanks


回答1:


You could open a socket and stream a few seconds from each video, saving the file locally on your Android device.

Once you have it there, so long as it is a recognisable video format, you should be able to create a thumbnail in the usual way (http://developer.android.com/reference/android/provider/MediaStore.Video.Thumbnails.html).

You would need to be careful to make sure that your app actually did not try to play these truncated videos, and went instead to the proper stream URL if someone wanted to view them. You could actually deleted the file after creating the thumbnail if you wanted to be sure.

Doing this may take a little time initially if your camera has a lot of videos, but you should be able to set it up to only create thumbnails for new videos once it has run once which should speed things up.

It is also possible to create thumbnails from streams directly using ffmpeg or VLC (e.g. https://superuser.com/q/592160) but I think you may find the above approach is simpler for your needs and it avoids you having to integrate ffmpeg etc with your app.



来源:https://stackoverflow.com/questions/30448389/how-to-get-video-thumbnail-if-i-have-the-rtsp-link-of-the-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!