1/6/2023 0 Comments Ffmpeg extract frames by fpsYou can also add the -vframes 8 option (where 8 is number_of_frames + 2) to skip the creation of the last image that you won't need anyway. Most probably there'll be a 9th image as well which can be discarded too. In the output the first two images should be discarded and the next 6 images (from 3rd til 8th) will be the ones we were looking for. Where -ss comes from the previous formula substituting the parameters from our example: 140 / ((6 + 1) * 10) = 2. To fix this you've to use the following command:įfmpeg -i input.avi -f image2 -ss 2 -r 0.05 frame-%05d.png After some thinking I got to the conclusion that the output is exactly duration / ((number_of_frames + 1) * 10) seconds offset backwards from the input video. the frame at 20s (the first frame that we wanted to save) is in case of a 24fps video the 480th frame, so the saved image should be the same as the frame-00480.png in the first command's output. Assuming that the first command (in this article) works OK, we can use its output to compare with the frames in the later examples. The first two images in the saved sequence will always be the first two frames of the input video (strange, isn't it? ) and the other images are not what we wanted. the output from the above command will not contain the frames that we targeted. It's either a bug or I'm not fully understanding how ffmpeg works. However this does not work as I expected. You can calculate the frame rate from the following expression: (number_of_frames + 1) / input_duration (in our example: (6 + 1) / 140 = 0.05. The -r option specifies the frame rate of the output stream (which is an image sequence in our example). Ffmpeg -i input.avi -f image2 -r 0.05 -vframes 6 frame-%05d.png
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |