How to convert a sequence of images to a video with different number of digits in the names

ffmpeg

I'd like to turn a sequence of images into a video using FFMPEG. They are numbered but with different "digits". Eg:

a0001.jpg

a0002.jpg

a0003.jpg

.

.

.

a654321.jpg

a654322.jpg

a654323.jpg

The first part consists of 4 digits but due to a very large number of images (more than a million). The number of digits can be up to 6.

after reading this wiki article, the following code didn't work:

ffmpeg -framerate 24 -i a%d.jpg video.webm

Error msg:

Could find no file with path 'a%d.jpg' and index in the range 0-4
a%d.jpg: No such file or directory

Version:

ffmpeg version N-92899-g1dcb5b7dca Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 43.100 / 58. 43.100
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100

Windows 10

Best Answer

Try the following:

ffmpeg -framerate 24 -i a%04d.jpg video.webm

Since you are starting with 3 leading zeros, %04d will begin with a0001.jpg. The sequence will continue with a10001.jpg (without any leading zeros) until no more files match the pattern (a654323.jpg in your case).

Related Question