Using FFMPEG to Batch Convert a Series of Separate Image Sequences

2.3k views Asked by At

I am trying to convert a large set of image sequences (each contained within its own subfolder) to video files. I can currently convert one sequence at a time by using ffmpeg and this code:

ffmpeg -r 30 -i "Image%%05d.jpg" -vf scale=1376:768 -qscale:v 2 "Display 1.m2v"

I also occasionally batch convert avi files which are contained within a single folder using:

for %%a in ("*.avi") do ffmpeg -i "%%a" -qscale:v 2 "%%~na.m2v"

I assumed I'd be able to use this batch approach with separate image sequences. What I’m having trouble with is figuring out the syntax for a similar batch code that will convert whatever image sequence is present in a folder (or subfolder) using the anyfile%%05d naming convention. The %%a syntax in the second line of code doesn’t seem to be compatible with the way ffmpeg recognizes image sequences anyfile%%05d in the first. Any thoughts?

1

There are 1 answers

0
AudioBubble On

According to your last comment all you need is then to:

  • iterate the subfolders of a base dir and evtl.
  • cd/pushd in there run your one working line and
  • step out and repeat until all subfolders are processd.

This is quite basic batch stuff.

@echo off

Pushd "X:\folder\to\start"
For /D %%A in (*) do (
    Pushd "%%~fA"
    ffmpeg -r 30 -i "Image%%05d.jpg" -vf scale=1376:768 -qscale:v 2 "Display 1.m2v"
    PopD
)
PopD