Rob Lourens
Rob Lourens

Reputation: 16109

ffmpeg with a set of image files not formatted as %d.jpg

I'm using ffmpeg to compile a set of jpgs into a video. There is plenty written about this, but it seems that the only way to do it is to have images named as consecutive padded numbers, e.g. 0001.jpg, 0002.jpg...

The ffmpeg documentation states that it is possible to use other types of patterns, such as %*.jpg to capture all *.jpg files, but the only pattern that I have gotten to work on my own is the %0Nd-type pattern. The man page only mentions that type.

I really want to have ffmpeg use a set of images with arbitrary names. It would simplify my app quite a lot, make it easier to keep thumbnails and metadata in sync as images are inserted and deleted, etc. Creating links is not an option since I'm working on Android. Is there any way to do this?

I'm also willing to modify the ffmpeg source or work with the C api to get it to do what I want, but I can't find the right spot in the code to do it, or appropriate docs for the C api. Any advice? Thanks.

Upvotes: 5

Views: 4535

Answers (1)

blahdiblah
blahdiblah

Reputation: 34031

The current docs for the image2 demuxer (not the same as the muxer that you linked!) suggest only two possibilities for names:

  • The filename pattern contains "%d" or "%0Nd" and frames are sequentially numbered, with the first frame being numbered no more than 4.
  • A single image can be used as input by specifying a name without a "%d" pattern.

I don't think there's likely to be support for arbitrarily named frame files as input any time soon because it's such an unusual case; most people care about the order of their frames, and the easiest way to order them is using sequential numbers.

That said, you might take a look at the concat input protocol which might be workable for your purposes. Be warned though, I couldn't get it to concatenate a few images just now in brief testing, so it may be limited to literally concatenatable formats like mpg.

Upvotes: 2

Related Questions