<p>The direct way to do this is by using the concat <a href="https://ffmpeg.org/ffmpeg-formats.html#concat-1" rel="nofollow noreferrer">demuxer</a>, where the text file only mentions the selected files. Besides being a hack, you no longer get to use the <code>image2</code> options. The better way is to combine your present commands.</p>

<pre><code>ffmpeg -framerate 20 -i frame-%d.png -vf "select='not(mod(n,20))'" -c:v mpeg4 -y movie.mp4 
</code></pre>

CC BY-SA 3.0
2017-02-13T14:34:01.160Z
This works only if all the frames are present. What If I have only `frame-0.png`, `frame-20.png`, `frame-40.png` available.
Grayrigel
CC BY-SA 3.0
2017-02-13T15:00:31.063Z
Then, you use the demuxer or pipe the images. To pipe, on Win: `cat *.png | ffmpeg -f image2pipe -framerate 1 -i - -r 20 -y out.mp4`
Gyan
CC BY-SA 3.0
2017-02-13T18:13:02.490Z
Command in comment above will also work on Linux & macOS.
llogan
CC BY-SA 3.0
2017-02-14T23:47:44.753Z
Also, I forgot about image autodetection, so you can likely omit the `-f`.
llogan
CC BY-SA 3.0
2017-02-13T13:35:47.163Z
2017-02-13T13:35:47.163Z
Gyan
<p>I have around 1000 frames in *.png format, which are named like <code>frame-0.png</code>, <code>frame-1.png</code>, <code>frame-2.png</code> and so on. I read them and generate a movie by following command :</p>

<pre><code>ffmpeg -f image2 -r 20 -i frame-%00d.png -vcodec mpeg4 -y movie.mp4 
</code></pre>

<p>Let's say I just want to read frames like <code>frame-0.png</code>,<code>frame-20.png</code>, <code>frame-40.png</code> and make a movie out of it. How can I achieve that ?</p>

<p>One possible way I know, is to make movie from all 1000 frames then generate a new movie by skipping frames from the following command :</p>

<pre><code>ffmpeg -y -i movie.mp4 -filter:v "select='mod(n,20)'" out.mp4
</code></pre>

<p>Is there any direct method ? </p>

<ffmpeg>
How to read frames which are separated by a specific number ? [ffmpeg]
Grayrigel
# How to read frames which are separated by a specific number ? [ffmpeg]

(Asked by: username_0 on 2017-02-13)

I have around 1000 frames in *.png format, which are named like frame-0.png, frame-1.png, frame-2.png and so on. I read them and generate a movie by following command :
ffmpeg -f image2 -r 20 -i frame-%00d.png -vcodec mpeg4 -y movie.mp4 

Let's say I just want to read frames like frame-0.png,frame-20.png, frame-40.png and make a movie out of it. How can I achieve that ?
One possible way I know, is to make movie from all 1000 frames then generate a new movie by skipping frames from the following command :
ffmpeg -y -i movie.mp4 -filter:v "select='mod(n,20)'" out.mp4

Is there any direct method ?

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2017-02-13. Score: 0 | Accepted answer

The direct way to do this is by using the concat demuxer, where the text file only mentions the selected files. Besides being a hack, you no longer get to use the image2 options. The better way is to combine your present commands.
ffmpeg -framerate 20 -i frame-%d.png -vf "select='not(mod(n,20))'" -c:v mpeg4 -y movie.mp4

> **Comments:**
> **username_0**: This works only if all the frames are present. What If I have only `frame-0.png`, `frame-20.png`, `frame-40.png` available.  
> **username_1**: Then, you use the demuxer or pipe the images. To pipe, on Win: `cat *.png | ffmpeg -f image2pipe -framerate 1 -i - -r 20 -y out.mp4`  
> **username_2**: Command in comment above will also work on Linux & macOS.  
> **username_2**: Also, I forgot about image autodetection, so you can likely omit the `-f`.  

---

