Shell – Who is doing the job: ffmpeg or the shell

ffmpegshell

First part of my question:

I read on the ffmpeg documentation (section 3.2 How do I encode single pictures into movies?) the following:

To encode single pictures into movies, run the command:

  ffmpeg -f image2 -i img%d.jpg movie.mpg    

Notice that `%d' is replaced by the image number:
img%03d.jpg means the sequence img001.jpg, img002.jpg, etc…

My question is: Who is doing the translation between img%03d.jpg and img001.jpg, img002.jpg, etc? Is it the shell or ffmpeg?

Second part:

I would like to ask ffmpeg to encode a sequence of images into a video. However, my sequences often start with an index different from 1, (e.g. we can call it start_index) and end on an index that we can call end_index. Moreover, the sequence uses increments of value increment, e.g.:

img_0025.png, img_0030.png, img_0035.png, ... img_0100.png

where start_index was 25, end_index was 100, and increment was 5.

I would like feed an image sequence like the above to ffmpeg without having to rename the sequence first. The documentation explains how to do this with symbolic links, but I was wondering if there is a way to avoid them altogether, maybe using advanced globbing on zsh.

Best Answer

Part 1: % is not a special character, so the img%d.jpg argument is passed as is to ffmpeg which “does the job” itself.

Part 2: Looking at ffmpeg documentation, I don't think there is another way to provide input files, so you may have to use symlinks or wait for the “fix”:

If the pattern contains "%d" or "%0Nd", the first filename of the file list specified by the pattern must contain a number inclusively contained between 0 and 4, all the following numbers must be sequential. This limitation may be hopefully fixed.

Related Question