Changes between Initial Version and Version 1 of Seeking

Jul 24, 2012, 11:50:24 PM (7 years ago)



  • Seeking

    v1 v1  
     1= Introduction =
     2If you need to extract only a specific part of your input, you'll need to use the seeking option to get to that specific part in the input first. [ The parameter -ss] is used to seek into the input and it can be used in several ways.
     4= Fast seeking =
     6(-ss parameter before -i)
     9ffmpeg -ss 00:03:00 -i Underworld.Awakening.avi -vframes 1 out1.jpg
     12This example will produce 1 image frame (out1.jpg) somewhere around 3rd minute from the beginning of the movie. The input will be parsed '''using keyframes''', which is '''very fast'''. The drawback is that it will also finish the seeking at some keyframe, not necessarily located at specified time (00:03:00), so the seeking will not be as accurate as expected.
     14= Accurate seeking =
     16(-ss parameter after -i)
     19ffmpeg -i Underworld.Awakening.avi -ss 00:03:00 -vframes 1 out2.jpg
     22This example will also produce 1 image frame (out2.jpg) precisely at 3rd minute from the beginning of the movie. The input is parsed '''very slowly''', frame by frame. The advantage is that you'll get the frame at exactly 3rd minute, but the drawback is that it will take a lot of time until it finally reaches that time point. The bigger the seeking time is, the longer you will have to wait.
     24= Fast and accurate seeking =
     26(-ss parameter before and after -i)
     29ffmpeg -ss 00:02:30 -i Underworld.Awakening.avi -ss 00:00:30 -vframes 1 out3.jpg
     32This approach is combining the best characteristics of both fast and accurate ways of seeking in FFmpeg. Shortly, we first seek very fast somewhere before the 3rd minute and then we slow down and seek frame by frame to the 3rd minute. This works because FFmpeg will first seek by keyframes, until it reaches at 00:02:30, when it will stop at the last keyframe found (somewhat before 00:02:30, depending on the [ gop size]/keyframes interval of the input) and then it will slowly seek the next 00:00:30 seconds to the desired time point. The result should be the same as in "Accurate seeking" section, only a lot faster.
     34For the reference, compare the attached images of out1.jpg, out2.jpg and out3.jpg