TheCodeNovice
TheCodeNovice

Reputation: 692

Deal with missing frames when creating video with ffmpeg

I am trying to assemble a video from a several thousands images that have been post processed by a vision script. The process is not perfect and I will have a few frames fail (like 20 out of 10K). My issue is I use a command like

ffmpeg -framerate 30 -start_number 11 -i image-%d.jpeg -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" movie.mp4

So this will fail as soon as it stumbles upon a failed image because it will be missing in the folder for example

Could not open file : image-727.jpegtrate=4305.2kbits/s speed=1.54x     
image-%d.jpeg: Input/output error

How can I get around this? I would like to avoid having to renumber so many files. I could have as many as 100K for a given run.

Thanks in advance.

Upvotes: 0

Views: 3075

Answers (1)

llogan
llogan

Reputation: 134173

Use the glob pattern type for the image demuxer:

ffmpeg -framerate 30 -pattern_type glob -i '*.jpeg' -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" movie.mp4

Because your file names do no appear to have any zero padding you will probably need to add sort:

cat $(find . -name '*.jpeg' -print | sort -V) | ffmpeg -framerate 30 -i - -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" movie.mp4

Upvotes: 1

Related Questions