ffmpeg – How can I create a 30-second GIF from a long and random video?

I have hundreds of videos in a folder for which I want to make a gif. The duration of each video is different, but all the videos last more than 30 seconds. I want to take 10 gifs of 3 3 seconds of a video during the course of the video. For example, if the video lasts 25 minutes and 3 seconds. Recorded The gif should be taken every 2.5 minutes (150 seconds).

The finished gifs must also have the same name as the video but ending in .gif all the videos are .mp4

The gifs must be 560×340.

It would be nice to do this with a command to.