Issue
I have some directory ./vis
that contains images that I want to loop through to generate a video. If I were to do it within one of the subdirectories, say ./vis/subdir1
I could run:
ffmpeg -framerate 10 -pattern_type glob -i '*.jpg' out.mp4
Now I want to generate videos for every single subdirectory, I tried this:
for d in */; do ffmpeg -framerate 10 -pattern_type glob -i '${d}*.jpg' "${d}".mp4"; done
But it does not seem to work. Any ideas?
Solution
- '${d}*.jpg' is wrapped with single quotes and the variable
d
is not interpolated. - "${d}".mp4" is not properly quoted. Besides, the variable
d
contains a trailing slash, which must be removed.
Then please try the following:
for d in */; do
ffmpeg -framerate 10 -pattern_type glob -i "$d*.jpg" "${d%/}.mp4"
done
Answered By - tshiono