How can I convert a video file to a sequence of images, for example one frame every N seconds. Can mplayer or ffmpeg do this? I have used MPlayer to grab screenshots manually but I would like to automate this for a long video.
Answer
mplayer -vo jpeg -sstep 5 file.avi
will save a frame as a jpeg file every 5 seconds.
However, it will not stop at the end of the file, it will continue producing copies of the last frame. To avoid this, find the duration of the video in seconds, using another player, or with mplayer:
mplayer -vo null -ao null -frames 0 -identify file.avi
and look for a line like "ID_LENGTH=147.00".
Subtract 2 from the length, and use this value for the -endpos
option. For example, for a 147 second video:
mplayer -vo jpeg -sstep 5 -endpos 145 file.avi
No comments:
Post a Comment