Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract frames using ffmpeg with corresponding frame number

I am trying to extract frames using FFMPEG using the following command:

 ffmpeg.exe ' -i ' videoFile ' -r 1/5 ' imgsFolder '\%5d.png'

Its extracting frames and assigning frame names in a sequential manner such 0, 1, ...

Is it possible to assign the actual frame number as part of the extraction?

For example, if the ffmpeg extracts 10th, 20th ...frames, it should name it img00010, img00020 instead of img00000, img00001....

like image 440
ssk Avatar asked Aug 09 '12 01:08

ssk


1 Answers

You can change the start number, by using '-start_number XX'.

But you can not change the increment of that number (I double checked with source code of ffmpeg).

Probably, it would be better to run a shell script that will rename your files. I can see that you are running in under Windows, so I'm not sure if you have bash there. But under linux it would look like this:

index=0
increment=10
prefix="new_"
for i in *.png; do printf "%s_%05d.png" $prefix $index; index=$[index+$increment]; done
like image 191
Dmitry Avatar answered Nov 09 '22 02:11

Dmitry