<p>While you can go with the links approach, suggested by <a href="https://video.stackexchange.com/users/1871/gyan">Gyan</a> in the comments. You could also generate a list of files that you want to use for encoding, and then use <code>-f concat</code>. I have tried it with the following:</p>
<pre><code>find . -name '*.jpeg' -exec echo &quot;file '&quot;{}&quot;'&quot; &gt;&gt; list.text \;
ffmpeg  -f concat -r 25 -safe 0 -i list.text -c:v libtheora -q:v 8 out.ogv
</code></pre>
<p>Let's take it apart.</p>
<p>First we generate the list of all the files matching '*.jpeg' name starting with the current directory <code>.</code>, we do not want to output that list as is, because <code>ffmpeg</code> for whatever reason cannot default to lines being files, and expects us to say it each and every line. So rather than <code>my_image_001.jpeg</code> we want <code>file 'my_image_001.jpeg'</code>. So we do a trick with the <code>-exec</code> of <code>find</code> piping the <code>echo</code> command into a file. <code>list.text</code> in this example.</p>
<p>Now we get to <code>ffmpeg</code>. You tell it that you wish to concatenate all of the files, by providing <code>-f concat</code> as the format of the file it is about to read. Note that you will need to specify the frame rate, since images do not have this at all. The <code>-safe 0</code> is needed so that <code>ffmpeg</code> does not crash and burn with <code>Unsafe file name</code> error message. I believe that is because we are using paths relative to the current directory. It makes little sense, but you just need to do this. After this, the line is the same as if you were just re-encoding another video.</p>

CC BY-SA 4.0
2021-12-05T08:53:14.093Z
Thanks. Good to see an alternative. But I did follow the link from Gyan May and it offers a cleaner solution for my business case.
Andrew Simpson
CC BY-SA 4.0
2021-12-04T05:51:12.017Z
2021-12-04T05:51:12.017Z
v010dya
<p>I know I can create a video from files in a folder like so:</p>

<pre><code>ffmpeg -f image2 -i %*.png out.avi
</code></pre>

<p>But if the folder I am in have sub-folders can i use some sort of switch to read those image files in those sub-folders?  At the moment I am having to copy these image files into 1 folder, create the video and then delete those copied image files. Which is time consuming .</p>

<p>Is there a way please?</p>

<p>Thanks</p>

CC BY-SA 4.0
2020-05-11T11:16:35.433Z
The image reader won't recurse folders. Instead of copying the images, create symlinks in one folder. Much faster. Or use the concat demuxer. See https://trac.ffmpeg.org/wiki/Slideshow#Concatdemuxer
Gyan
CC BY-SA 4.0
2020-05-16T11:26:49.073Z
many thanks  only had the time now to look at this:)
Andrew Simpson
<ffmpeg><windows><linux>
Using FFMPEG to create video from images in sub folders
Andrew Simpson
# Using FFMPEG to create video from images in sub folders

(Asked by: username_0 on 2020-05-11)

I know I can create a video from files in a folder like so:
ffmpeg -f image2 -i %*.png out.avi

But if the folder I am in have sub-folders can i use some sort of switch to read those image files in those sub-folders?  At the moment I am having to copy these image files into 1 folder, create the video and then delete those copied image files. Which is time consuming .
Is there a way please?
Thanks

**Tags:** ffmpeg, windows, linux

> **Comments:**
> **username_1**: The image reader won't recurse folders. Instead of copying the images, create symlinks in one folder. Much faster. Or use the concat demuxer. See https://trac.ffmpeg.org/wiki/Slideshow#Concatdemuxer  
> **username_0**: many thanks  only had the time now to look at this:)  

---

## 1 answers

### Answer by username_2 on 2021-12-04. Score: 1

While you can go with the links approach, suggested by username_1 in the comments. You could also generate a list of files that you want to use for encoding, and then use -f concat. I have tried it with the following:
find . -name '*.jpeg' -exec echo "file '"{}"'" >> list.text \;
ffmpeg  -f concat -r 25 -safe 0 -i list.text -c:v libtheora -q:v 8 out.ogv

Let's take it apart.
First we generate the list of all the files matching '*.jpeg' name starting with the current directory ., we do not want to output that list as is, because ffmpeg for whatever reason cannot default to lines being files, and expects us to say it each and every line. So rather than my_image_001.jpeg we want file 'my_image_001.jpeg'. So we do a trick with the -exec of find piping the echo command into a file. list.text in this example.
Now we get to ffmpeg. You tell it that you wish to concatenate all of the files, by providing -f concat as the format of the file it is about to read. Note that you will need to specify the frame rate, since images do not have this at all. The -safe 0 is needed so that ffmpeg does not crash and burn with Unsafe file name error message. I believe that is because we are using paths relative to the current directory. It makes little sense, but you just need to do this. After this, the line is the same as if you were just re-encoding another video.

> **Comments:**
> **username_0**: Thanks. Good to see an alternative. But I did follow the link from username_1 May and it offers a cleaner solution for my business case.  

---

