Short Problem: I want to take some screenshots image from a video url at some specific times but I don't want to read the whole video.

Let's say I have a video stored in some url (like https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4). The size of video is large but we can seek on the video.

Now I want to take 4 screenshots/thumbnails of the video. Like if the video's size is 100s, I want to take screenshots at 20s, 40s, 60s and 80s.

Using the tutorial from wiki:Create a thumbnail image every X seconds of the video I can do this

ffmpeg -i 'https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4' -vf fps=1/20 img%03d.jpg

But the problem with this approach is it read the whole input before returning the screenshots. But as the input is seekable this seems waste. Better approach is to seek to the positions and take them. For now we are using something like

for i in 20 to 80 step 20
    ffmpeg -noaccurate_seek -ss {i} -i 'https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4' -vframes 1 out-{i}.png

This seems work but still running each ffmpeg takes some time and each ffmpeg decode the header of the same video url which seems redundant. Is there any way so that in a single ffmpeg call so this duplicate works can be removed?

P.S. There is no need for an answer only using ffmpeg. We can also use mpv/mplayer or vlc or any other player/converter available in Linux.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.