Image sequence handling in ffmpeg

0

I need to convert an image folder with unnumbered names, like:

11.49.18.204.jpg
11.49.28.205.jpg
11.49.38.220.jpg
11.49.48.220.jpg
11.49.58.235.jpg
11.50.08.250.jpg

FFMPEG only accepts numbered inputs. The original file names are important to me. So much that I plan to overlay them on the video feed. I think I need to use SRT subtitle input with text overlay option.

I would like to know how I can make this work.

For example, this will not work

ffmpeg -i *.jpg

yoshco

Posted 2015-03-17T16:48:56.450

Reputation: 384

Answers

2

ok, apparently FFMPEG does support name globing, from ffmpeg.org/wik

ffmpeg also supports bash-style globbing (* represents any number of any characters). This is useful if your images are sequential but not necessarily in a numerically sequential order as in the previous examples.

ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4

yoshco

Posted 2015-03-17T16:48:56.450

Reputation: 384

0

If you are on Unix/Linux, this bash script line will rename a directory of image files to a series of sequential names that will work with ffmpeg. Basically it creates an in memory buffer of all the existing filenames, and then loops thru each name, moving them to an incrementally numbered name (in the same directory.

x=1; for i in *jpg; do counter=$(printf %03d $x); mv "$i" img"$counter".jpg; x=$(($x+1)); done

jdh

Posted 2015-03-17T16:48:56.450

Reputation: 6 645

if i understand, this will create a duplicate of each file in folder , as in a real copy? this will create a lot of mess. but might be an option – yoshco – 2015-03-17T17:35:01.847

No, "mv" in unix renames a file. So there will only be one copy. – jdh – 2015-03-17T17:47:22.047

sorry, cant see how to use this. i want to keep the original file names. your one liner just renamed the entire folder. which was a dup so no harm done.
but you should mention that as a disclimer. for the next guy.
– yoshco – 2015-03-17T18:10:56.443

apparently FFMPEG faq recondes your method

http://www.ffmpeg.org/faq.html#toc-How-do-I-encode-single-pictures-into-movies_003f even $(ls -r -t *jpg)

– yoshco – 2015-03-17T19:02:30.237

@yoshco - you need to cd to the directory where your jpg files are first. If your directory was renamed with the above script, it must have ended with .jpg. If you want to keep the files and make a copy to a new directory, you can change the "mv .." part to a copy, like this: cp "$i" yourNewDirectoryName"$counter".jpg – jdh – 2015-03-17T19:10:09.343

its a valid answer, but i dont want to have to mv gigs of data just to rename them. btw, globbing doesn't seem to work for windows. and ffmpeg is picky about what jpg it likes. even on bleeding linux/arch.

the best approach for me would have support for reading a list of paths from a txt file. that would be awesome – yoshco – 2015-03-17T23:02:57.763

@yoshco Regarding the pickyness, all images in the sequence should have the same frame size and pixel format (the console output will mention if they change). If they change it can result in weird timing or skipped images. – llogan – 2015-04-06T16:03:04.023