Search code examples
powershellvideoffmpegmp4strftime

How to create a video from frames named using timestamp with ffmpeg


I have a folder filled with frames that have the timestamp in the name in the folowing format

im_%H_%M_%S_%MS.png

im_08_05_09_007324.png
im_08_05_09_532857.png
im_08_05_10_059340.png
im_08_05_10_575862.png
im_08_05_11_118361.png
im_08_05_11_596814.png
im_08_05_12_148340.png
im_08_05_12_665838.png

I try to use -pattern_type glob in windows but it does not work.

ffmpeg.exe -framerate 10 -pattern_type glob -i im_*.png -c:v libx264 -r 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"  -pix_fmt yuv420p $videoName

I get

 Pattern type 'glob' was selected but globbing is not supported by this libavformat build im_*.png: Function not implemented

later I found that this do not work on windows :( which is what I am using. ffmpeg Error: Pattern type 'glob' was selected but globbing is not support ed by this libavformat build

I also try

ffmpeg.exe -framerate 10 -pattern_type glob -i im_%02d_%02d_%02d_%06d.png -c:v libx264 -r 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"  -pix_fmt yuv420p $videoName

I got

im_%02d_%02d_%02d_%06d.png: No such file or directory

I am running out of ideas. I refuse to believe that there is no way to do this in ffmpeg and powershell. I really appreciate any help!


Solution

  • You can use a workaround, via the concat demuxer

    Create a text file with the list of filenames in order

    file im_08_05_09_007324.png
    file im_08_05_09_532857.png
    file im_08_05_10_059340.png
    file im_08_05_10_575862.png
    file im_08_05_11_118361.png
    

    and then run

    ffmpeg -f concat -r 10 -i list.txt -c:v libx264 ...
    

    (this will produce warnings about invalid DTS but you can ignore them)