Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard for sequential images

I'm trying to animate a series of jpg files using avconv. Based on numerous examples, I'm trying using %d.jpg to specify the files. Or %05d.jpg. However, I'm getting:

avconv -i %d.jpg a.avi
avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers built on Jun 12 2012 16:37:58 with gcc 4.6.3
%d.jpg: No such file or directory

Here is a snip of my directory listing:

10380.jpg
10390.jpg
10400.jpg
1040.jpg
10410.jpg
10420.jpg
10430.jpg
10440.jpg

There are jpegs from 00000.jpg to 14400.jpg

I don't really understand that wildcard system, but that is what is in examples.

(note: I tagged it ffmpeg because a tag for avconv does not exist, and avconv supersedes ffmpeg)

Update I'm updating the question based on the answer below by @av501.

To begin with, I have a list of png files with sequential ordering by 10. They have text preceding a 5 digit integer. For example:

SkinMattekNutrient_py_00000.png
SkinMattekNutrient_py_00010.png
SkinMattekNutrient_py_00020.png
...
SkinMattekNutrient_py_10440.png

What would be the way to batch convert these to jpg? I tried

convert ...
SkinMattekNutrient_py_%05d.png %05d.jpg

and

convert ...
SkinMattekNutrient_py_%5d.png %5d.jpg

But I get:

convert SkinMattekNutrient_py_%05d.png %05d.jpg
convert: missing an image filename `%05d.jpg' @ error/convert.c/ConvertImageCommand/3011.
like image 1000
abalter Avatar asked Sep 11 '12 02:09

abalter


2 Answers

You need to use %5d for your files. But you seem to have two problems

For %5d to work you must have 5 digit numbering. [You have a 1040.jpg] and also consecutive. 00000.jpg then 00001.jpg. Your file names seem to be jumping by 10.

If all of them are multiple of 10, then you can use %d50.jpg [But you still need to fix your 1040.jpg]

Otherwise the command line works here [I am using ffmpeg -i %5d.jpg out.avi and ffmpeg -i %5d0.jpg out.avi]

like image 62
av501 Avatar answered Sep 28 '22 04:09

av501


Here's one way to batch-convert image files in a Bash shell:

for f in *.png; do ffmpeg -i "$f" "${f%.png}.jpg"; done

I believe this technique will work for any command which requires input and output files to be listed separately. In your case this would be:

for f in *.png; do convert "$f" "${f%.png}.jpg"; done
like image 37
meetar Avatar answered Sep 28 '22 05:09

meetar