8

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

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

user96155
  • 81
  • 1
  • 1
  • 2
  • Why? Do you want to join them all together? Or do you want to perform the same operation on each file and save the output to separate files? `ffmpeg` / `avconv` doesn't support wildcards, but there are various ways around that. Eg `ffmpeg $(printf -- "-i %s " *.mp4)` – PM 2Ring Dec 27 '14 at 13:53
  • @PM 2Ring I have 10 videos of one hour and I want them in 10 minute clips. What does your code do? Is there a way to escape ffmpeg, put the wildcard and go back in? – user96155 Dec 27 '14 at 14:04
  • If you give `ffmpeg` an input file with no output file, then it just prints some info about the file. So that command in my previous comment prints some info about every `.mp4` file in the current directory. – PM 2Ring Dec 27 '14 at 14:09
  • Generally, wildcard expansion is handled by the shell, (i.e. the shell converts your wildcard expression into a bunch of filenames & passes that to the command) but some commands have their own wildcard handling. `ffmpeg` doesn't do wildcards, but it can handle numbered sets of files using `%d` notation, both for input and output. – PM 2Ring Dec 27 '14 at 14:15
  • For your application, you should pass one filename at a time to `ffmpeg`, which you can do with a bash `for` loop. Do you need help with that? FWIW, there's an example command to segment a video file into parts in [this answer](http://unix.stackexchange.com/a/148862/88378). – PM 2Ring Dec 27 '14 at 14:29

1 Answers1

9

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.

billyw
  • 273
  • 3
  • 4