Answers.Body: <p>You probably just need to adjust the pts with: <code>setpts=PTS+(94*TB)</code>.
  You would need to adjust that 94 for each different start number<br>
  So: </p>
  
  <pre><code>ffmpeg -start_number 94 -i source.%04d.png -filter_complex select='eq(n\,2)+eq(n\,80)+eq(n\,150)';setpts=PTS+(94*TB) frames_%04d.jpeg
  </code></pre>
  
  <p>Also <code>vsync</code> is a bit unnecessary when outputting to jpg.  </p>
  
  <p>EDIT: Fixed the <code>setpts</code>-Expression, because I was stupid the first time.
  EDIT2: I can't even read the question properly it seems... Fixed the <code>setpts</code>-Expression again</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T09:56:37.570Z
Answers.Text: Default vsync for images is CFR and so ffmpeg will duplicate frames when the timestamps between output frames is greater than that expected for adjacent frames. vsync 0 is needed to disable that.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-25T11:55:07.937Z
Answers.LastActivityDate: 2020-05-25T12:27:09.480Z
Answers.LastEditDate: 2020-05-25T12:27:09.480Z
Answers.UserDisplayName: Pingger Shikkoken
Answers.Body: <p><code>start_number</code> is ignored with frame_pts, so a workaround is needed. A generic option <code>output_ts_offset</code> is available but it takes timestamp rather than frame number, so we first set the framerate of the images input as 1.</p>
  
  <p>Use</p>
  
  <pre><code>ffmpeg -start_number 94 -framerate 1 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -output_ts_offset 94 -frame_pts 1 frames_%04d.jpeg
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-20T07:43:24.987Z
Answers.LastActivityDate: 2020-05-20T07:43:24.987Z
Answers.UserDisplayName: Gyan
Body: <p>I'm doing some ffmpeg (4.1.3) transcodings by extracting specific frames from the source, in this case, the source can be either a movie or an image sequence, all working fine with the following command:</p>
  
  <pre><code>ffmpeg -i source.mov -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -frame_pts 1 frames_%04d.jpeg
  </code></pre>
  
  <p>In the case of a source image sequence, I only need to specify the start number (since my frames usually start in 100 or further):</p>
  
  <pre><code>ffmpeg -start_number 94 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -frame_pts 1 frames_%04d.jpeg
  </code></pre>
  
  <p>But the issue is that the frame numbers that I get match the exact numbers that I asked for, which are those required from the select filter and start at 0, in the example of the image sequence, you can see that it actually starts at frame 94, and technically the movies replicate the same, their first frame is the same as 94 in image sequence, and i will love to have a way to get the output numbers be offset by a certain number so they match the corresponding "source" frame.</p>
  
  <p>I already tried adding a <strong>-start_number</strong> at the end before the output, which works with regular transcodes, but it seems not to work in combination of <strong>-frame_pts</strong></p>
  
  <p>I will love to be able to do something like this:</p>
  
  <pre><code>ffmpeg -start_number 94 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -start_number 94 -frame_pts 1 frames_%04d.jpeg
  </code></pre>
  
  <p>And get frame 96, 174 and 244 instead of 2, 80 and 150.</p>
  
  <p>Is there a way to do that ?</p>
  
  <p>Thanks in advanced!</p>
  
Tags: <ffmpeg><encoding><transcoding>
Title: FFMPEG: is it possible to offset output frames from a selection of specific frames?
UserDisplayName: hasielhassan
ThreadText: # FFMPEG: is it possible to offset output frames from a selection of specific frames?
  
  (Asked by: username_0 on 2020-05-19)
  
  I'm doing some ffmpeg (4.1.3) transcodings by extracting specific frames from the source, in this case, the source can be either a movie or an image sequence, all working fine with the following command:
  
  ```
  ffmpeg -i source.mov -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -frame_pts 1 frames_%04d.jpeg
  
  ```
  
  In the case of a source image sequence, I only need to specify the start number (since my frames usually start in 100 or further):
  
  ```
  ffmpeg -start_number 94 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -frame_pts 1 frames_%04d.jpeg
  
  ```
  
  But the issue is that the frame numbers that I get match the exact numbers that I asked for, which are those required from the select filter and start at 0, in the example of the image sequence, you can see that it actually starts at frame 94, and technically the movies replicate the same, their first frame is the same as 94 in image sequence, and i will love to have a way to get the output numbers be offset by a certain number so they match the corresponding "source" frame.
  
  I already tried adding a **-start\_number** at the end before the output, which works with regular transcodes, but it seems not to work in combination of **-frame\_pts**
  
  I will love to be able to do something like this:
  
  ```
  ffmpeg -start_number 94 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -start_number 94 -frame_pts 1 frames_%04d.jpeg
  
  ```
  
  And get frame 96, 174 and 244 instead of 2, 80 and 150.
  
  Is there a way to do that ?
  
  Thanks in advanced!
  
  **Tags:** ffmpeg, encoding, transcoding
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-05-25. Score: 0
  
  You probably just need to adjust the pts with: `setpts=PTS+(94*TB)`.
  You would need to adjust that 94 for each different start number  
  So:
  
  ```
  ffmpeg -start_number 94 -i source.%04d.png -filter_complex select='eq(n\,2)+eq(n\,80)+eq(n\,150)';setpts=PTS+(94*TB) frames_%04d.jpeg
  
  ```
  
  Also `vsync` is a bit unnecessary when outputting to jpg.
  
  EDIT: Fixed the `setpts`-Expression, because I was stupid the first time.
  EDIT2: I can't even read the question properly it seems... Fixed the `setpts`-Expression again
  
  > **Comments:**
  > **username_2**: Default vsync for images is CFR and so ffmpeg will duplicate frames when the timestamps between output frames is greater than that expected for adjacent frames. vsync 0 is needed to disable that.  
  
  ---
  
  ### Answer by username_2 on 2020-05-20. Score: 0
  
  `start_number` is ignored with frame\_pts, so a workaround is needed. A generic option `output_ts_offset` is available but it takes timestamp rather than frame number, so we first set the framerate of the images input as 1.
  
  Use
  
  ```
  ffmpeg -start_number 94 -framerate 1 -i source.%04d.png -vf select='eq(n\,2)+eq(n\,80)+eq(n\,150)' -vsync 0 -output_ts_offset 94 -frame_pts 1 frames_%04d.jpeg
  
  ```
  
  
  ---
  
  