0

I have several hours of CCTV footage that I'd like to reasonably quickly skim. If there was a way to take every say 60th frame from it and put together a video from those frames that would be perfect.

Is there a ffmpeg command that does that in one go? Or do I have to extract the frames first, and then encode a video from them?

1 Answer 1

2

See FFmpeg documentation regarding select filter https://ffmpeg.org/ffmpeg-filters.html#Examples-160, so to keep every 60th frame use -vf "select=not(mod(n\,60))"

And this has been already discussed with another example here Using select in ffmpeg to choose frames

5
  • What it does is insert every 60th frame 60 times in the result video so that the overall frame count (and length of the video) stays the same. I need every 60th frame only once so that the video is sped up accordingly.
    – Greendrake
    Commented Jan 24, 2023 at 1:41
  • 1
    For that scenario try using -vf "select=not(mod(n\,60)),setpts=N/FR/TB" which should rebase timestamps according to the filtered frames only.
    – tbucher
    Commented Jan 24, 2023 at 11:48
  • The result is still botched. The video shows one still frame for the almost entire length of it and then the whole bunch of the rest of the selected frames at the end. No timing balance between the frames. Would you please try this on your own and update the answer with a 100% working solution so that it can be accepted?
    – Greendrake
    Commented Jan 25, 2023 at 23:28
  • It does work fine according to my test with a source that has each frame burned with a timestamp. Applying the filter does what it is supposed to and seeking frame by frame in the result then shows correct frames and the video behaves just fine when played back normally. One thing that comes to mind based on your description: does your source have an audio track as well? In that case it needs to be omitted by using additional parameter "-an" in the commandline or it would have to be filtered and shortened as well, but the result would be then unlistenable.
    – tbucher
    Commented Jan 26, 2023 at 10:45
  • It was the audio track messing up indeed. Thank you!
    – Greendrake
    Commented Jan 26, 2023 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.