windowsbatch-fileffmpeg

ffmpeg not using wildcard properly from batch script


What I want to do is actually super simple and is working just fine if executed from within the cmd window, though it does not work when used within a batch script. The following command would normally get all .png files with the pattern anim_xxxx.png (%04d stands for 4 numbers in ffmpeg).

ffmpeg -f image2 -i anim_%04d.png -vcodec mjpeg -q:v 0 -r 25 foo.avi

Now the error I get is with the wildcard for my image sequence and I have no clue what the problem is. Using another wildcard like * gives me the same error.

[image2 @ 000000000033e8c0] Could find no file with with path 'anim_render.bat4d.png' and index in the range 0-4 anim_render.bat4d.png: No such file or directory

does %04d resemble any variable in a batch file that does not exist outside of batch files? I could not find any similar cases so far.


Solution

  • No idea what %04 means as far as FFMPEG is concerned, although anim_*.mpg would seem a more commonly understood method of specifying all starting 'anim_' Perhaps it's a special meaning +any 4 characters (although ???? would seem more common here.

    Nevertheless, it would appear that ffmpeg is expecting that the % is supplied literally so the cure in batch would be to precede the % with a caret : ^%

    Erm- make that double the % - ^x normally works with characters that have a special meaning in batch; seems you need % to escape %...