Answers.Body: <p>See FFmpeg documentation regarding <code>select</code> filter <a href="https://ffmpeg.org/ffmpeg-filters.html#Examples-160" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#Examples-160</a>, so to keep every 60th frame use <code>-vf &quot;select=not(mod(n\,60))&quot;</code></p>
  <p>And this has been already discussed with another example here <a href="https://video.stackexchange.com/questions/32756/using-select-in-ffmpeg-to-choose-frames">Using select in ffmpeg to choose frames</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T01:41:16.373Z
Answers.Text: 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.
Answers.UserDisplayName: Greendrake
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T11:48:57.347Z
Answers.Text: 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.
Answers.UserDisplayName: tbucher
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-25T23:28:29.633Z
Answers.Text: 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?
Answers.UserDisplayName: Greendrake
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-26T10:45:37.320Z
Answers.Text: 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.
Answers.UserDisplayName: tbucher
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-26T11:21:18.670Z
Answers.Text: It was the audio track messing up indeed. Thank you!
Answers.UserDisplayName: Greendrake
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-23T15:53:28.323Z
Answers.LastActivityDate: 2023-01-23T15:53:28.323Z
Answers.UserDisplayName: tbucher
Body: <p>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.</p>
  <p>Is there a <code>ffmpeg</code> command that does that in one go? Or do I have to extract the frames first, and then encode a video from them?</p>
  
Tags: <ffmpeg><encoding>
Title: How to re-encode leaving only every Nth frame in?
UserDisplayName: Greendrake
ThreadText: # How to re-encode leaving only every Nth frame in?
  
  (Asked by: username_0 on 2023-01-10)
  
  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?
  
  **Tags:** ffmpeg, encoding
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-23. Score: 2 | Accepted answer
  
  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](https://video.stackexchange.com/questions/32756/using-select-in-ffmpeg-to-choose-frames)
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_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.  
  > **username_0**: 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?  
  > **username_1**: 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.  
  > **username_0**: It was the audio track messing up indeed. Thank you!  
  
  ---
  
  