How to use a wildcard in FFMPEG

ffmpeg

Lets say I want every .mp4 file in a folder as an input file.

How does one do that? It only reads it literal.

Best Answer

You're dealing with a directory of videos, so you will probably need to use a loop. The following loop will split each matched file into ten minute segments, as requested in your comment:

for i in *.mp4; do 
    ffmpeg -i "$i" -c copy \
    -f segment -segment_time 600 \
    -reset_timestamps 1 \
    "${i/%.mp4/_part%02d.mp4}"; 
done

However, if your input is a directory of images, then the image2 demuxer lets you use wildcards. Just specify -pattern_type glob and pass your glob pattern to -i in a non-interpolated string (so that the shell does not expand it).

For example, I did the following when converting a directory of JPEG files to an MPEG-4 video:

ffmpeg -f image2 -pattern_type glob -i '*.jpg' output.mp4

Just be aware that this depends entirely on the glob pattern to determine the order that the matched image files are processed.

Related Question