I am using FFmpeg I'd like to create an mp4 using an image sequence.
But the images are not named sequentially, like 1, 2, 3, 4... Instead they are named with a time stamp in the form yyyy-mm-dd-mm.
How can I create a script to achieve this?
Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It only takes a minute to sign up.
Sign up to join this communityI am using FFmpeg I'd like to create an mp4 using an image sequence.
But the images are not named sequentially, like 1, 2, 3, 4... Instead they are named with a time stamp in the form yyyy-mm-dd-mm.
How can I create a script to achieve this?
You can do it with scripting by renaming the files. I don't have a Windows machine at hand at the moment so I can't test this but this is what I would do in power shell:
First navigate to the directory containing the image sequence, then
mkdir sorted_images;
$serial=0;
Get-childItems *. jpg | sort-object date | %{
Cp $_ (".\sorted_images\image_{0}.jpg" -f ($serial.toString("00000")));
$serial++}
That script should copy all the jpg images in the current folder to a new folder and rename them with a five digit serial number. Try it out on some test images first because I haven't tested it myself.
It's rather a powershell-specific question than FFmpeg, but here you go:
ffmpeg -i <input> <some_encoding_options> -f mp4 "my_filename_"$(get-date).ToString("yyyy-MM-dd_HH-mm")".mp4"
Change the parameter of ToString
to whatever you want, you can find more info about PS date formatting syntax here.
A little cheatsheet (all of these have leading zeroes):
yyyy
yearMM
monthdd
dayhh
hour in 12-hour formatHH
hour in 24-hour formatmm
minute