<p>You cannot use <code>-r</code> and <code>-filter_complex</code> together. They are different ways of changing the frame rate. <code>-r</code> is an input or output option. <code>-filter_complex</code> is a <code>filtergraph</code> option. They have different logic and behavior.
You may try this command:</p>
<pre><code>ffmpeg -i myvideo.mp4 -vf “select=‘gte(n,3)’,setpts=N/10/TB” my10fpsvideo.mp4
</code></pre>
<p>This will skip the first three frames and then change the frame rate to 10 using the <code>setpts</code> filter. It should give you the same result as <code>-r 10</code> and then skipping two frames. However, I do not know if it works for variable frame rate input. You have to test it yourself.</p>
<p>I hope this helps.</p>

CC BY-SA 4.0
2023-11-02T08:41:21.607Z
thank you for your answer, unfortunately, it doesn work even in CFR, if I understood correctly, to get X fps and start at frame F, I should enter the command:
ffmpeg -i myvideo.mp4 -vf “select=‘gte(n,<F+1>)’,setpts=N/<X>/TB” my10fpsvideo.mp4

When I try your exact example for frame 2 at 10 fps, I get the frames: [3,3,4,4,5,5,5,6,6,7]
BlueMagma
CC BY-SA 4.0
2023-11-02T08:16:26.843Z
2023-11-03T01:57:42.150Z
2023-11-03T01:57:42.150Z
Camera Man
<p>When converting the framerate of a video, ffmpeg offers multiple options</p>
<p>one options is <code>-r</code>:</p>
<pre><code>ffmpeg -i myvideo.mp4 -r 10 my10fpsvideo.mp4
</code></pre>
<p>another option is using filters:</p>
<pre><code>ffmpeg -i myvideo.mp4 -filter_complex [0]fps=fps=10[s0] -map [s0] my10fpsvideo.mp4
</code></pre>
<p>Using the second option I can apply further filters on the changed fps stream, like selecting a start frame number for exemple <code>select=gte(n,42)</code></p>
<p>Both these solutions don't return the same frames from the original video:</p>
<pre><code>-r 10 return the frame indexes  0,1,2,4,7,9,12...
-filter_complex returns indexes     1,3,6,8,11...
</code></pre>
<p>As you can see <code>-r</code> somehow shift the output video by 2 frames and doesn't return the same frames as <code>-complex_filter</code></p>
<p>My problem is I need to apply that start frame number filters, but I also need to extract the exact frames from the original video as <code>-r</code> would do</p>
<p>For exemple: If I convert to 10 fps and want to start at frame index <code>3</code> I should receive frames <code>4,7,9,12...</code>, the frame I would have gotten if had changed framerate using <code>-r</code> and skipped the result's first 2 frame</p>
<p>I am constrained to the exact frames returned by <code>-r</code> by legacy data that relies on these specific frames to be returned. I am also constrained by the fact that input can be VFR and I can't precompute what frames I need to extract for a given framerate.</p>
<p>Right now the only solution I've found is to read the entire video and discard all frame up to that frame number, which is long and cost a lot of resources.</p>
<p>Is there any way to do what I'm trying to do ?</p>

CC BY-SA 4.0
2023-11-02T17:28:47.537Z
Did you just delete an earlier instance of this Q that I answered?
Gyan
CC BY-SA 4.0
2023-11-04T08:39:16.640Z
@gyan Yes, another user pointed out that this was out of topic on stack overflow and needed to be deleted and reposted on video.stackexchange, which is what I did
BlueMagma
CC BY-SA 4.0
2023-11-04T15:15:00.043Z
a) you aren't obliged to follow that, b) see your deleted questions and refer to my answer for a solution
Gyan
<ffmpeg>
Replicate the behavior of -r option before applying filters
BlueMagma
# Replicate the behavior of -r option before applying filters

(Asked by: username_0 on 2023-11-02)

When converting the framerate of a video, ffmpeg offers multiple options
one options is -r:
ffmpeg -i myvideo.mp4 -r 10 my10fpsvideo.mp4

another option is using filters:
ffmpeg -i myvideo.mp4 -filter_complex [0]fps=fps=10[s0] -map [s0] my10fpsvideo.mp4

Using the second option I can apply further filters on the changed fps stream, like selecting a start frame number for exemple select=gte(n,42)
Both these solutions don't return the same frames from the original video:
-r 10 return the frame indexes  0,1,2,4,7,9,12...
-filter_complex returns indexes     1,3,6,8,11...

As you can see -r somehow shift the output video by 2 frames and doesn't return the same frames as -complex_filter
My problem is I need to apply that start frame number filters, but I also need to extract the exact frames from the original video as -r would do
For exemple: If I convert to 10 fps and want to start at frame index 3 I should receive frames 4,7,9,12..., the frame I would have gotten if had changed framerate using -r and skipped the result's first 2 frame
I am constrained to the exact frames returned by -r by legacy data that relies on these specific frames to be returned. I am also constrained by the fact that input can be VFR and I can't precompute what frames I need to extract for a given framerate.
Right now the only solution I've found is to read the entire video and discard all frame up to that frame number, which is long and cost a lot of resources.
Is there any way to do what I'm trying to do ?

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Did you just delete an earlier instance of this Q that I answered?  
> **username_0**: @gyan Yes, another user pointed out that this was out of topic on stack overflow and needed to be deleted and reposted on video.stackexchange, which is what I did  
> **username_1**: a) you aren't obliged to follow that, b) see your deleted questions and refer to my answer for a solution  

---

## 1 answers

### Answer by username_2 on 2023-11-02. Score: 0

You cannot use -r and -filter_complex together. They are different ways of changing the frame rate. -r is an input or output option. -filter_complex is a filtergraph option. They have different logic and behavior.
You may try this command:
ffmpeg -i myvideo.mp4 -vf “select=‘gte(n,3)’,setpts=N/10/TB” my10fpsvideo.mp4

This will skip the first three frames and then change the frame rate to 10 using the setpts filter. It should give you the same result as -r 10 and then skipping two frames. However, I do not know if it works for variable frame rate input. You have to test it yourself.
I hope this helps.

> **Comments:**
> **username_0**: thank you for your answer, unfortunately, it doesn work even in CFR, if I understood correctly, to get X fps and start at frame F, I should enter the command: ffmpeg -i myvideo.mp4 -vf “select=‘gte(n,<F+1>)’,setpts=N/<X>/TB” my10fpsvideo.mp4  When I try your exact example for frame 2 at 10 fps, I get the frames: [3,3,4,4,5,5,5,6,6,7]  

---

