Wildcard for sequential images
Asked Answered
G

2

6

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.
Gonad answered 11/9, 2012 at 2:17 Comment(0)
H
7

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]

Hedy answered 11/9, 2012 at 4:58 Comment(3)
I updated my question to make it simpler -- simply about converting the png files to jpg. I still can't figure out how to properly use the wildcard system. I've tried searching, but can't find any explanations. What would be the correct syntax? Thanks.Gonad
convert is a different utility, right? ffmpeg is a different one. I am doing it using ffmpeg and it works fine here.Hedy
Regardless of which program I'm using, I'm getting the can't find file error. I wonder what is wrong with my system? All examples I've found show the same thing.Gonad
L
5

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
Lepidus answered 9/12, 2012 at 20:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.