1

So i have a folder with only mp4 files. I just want to get specific frames for every mp4 files automatically. I tried the below command, but it tried overwriting the mp4 file, is there any error with the below command? So i expect to input a mp4 file and to get 3 frames in .jpg format.

for i in *.mp4; do 
   ffmpeg -i *.mp4 -vf select='eq(n\,10)+eq(n\,17)+eq(n\,21)' -vsync 0 frames%d.jpg
done
Walter A
  • 19,067
  • 2
  • 23
  • 43
  • This is a batch/shell problem. Add the appropriate tags along with OS info.. – Gyan Feb 22 '18 at 07:19
  • 1
    You are looping over `*.mp4` but never use `$i`. Do you want `frames%d.jpg` filled with a number? – Walter A Feb 22 '18 at 08:59
  • @WalterA yes, i want it to be filled with a number. However, even after i added done to the code, it still asks to overwrite the mp4 file – Idham Halim Feb 22 '18 at 09:09
  • 1
    `frames%d.jpg` is passed on to ffmpeg, whose image sequence muxer, will generate frames1.jpg, frames2.jpg.... That's not a problem. But ffmpeg does not do batch ingest or sequential processing of videos, so it can't accept `*.mp4`. That's a shell issue. Suggest `-i "$i"` and `${i%.*}-frames%d.jpg` – Gyan Feb 22 '18 at 09:27

1 Answers1

1

I am no expert on ffmpeg but you have some fairly fundamental issues in your script. Hopefully, this will get you started:

for i in *.mp4; do 
   ffmpeg -i "$i" -vf select='eq(n\,10)+eq(n\,17)+eq(n\,21)' -vsync 0 "${i%.*}_frames%d.jpg"
done
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432