I have a folder with videos files and need to extract 2+ frames from each of these, using a bash script on Linux. Currently I am doing this for each video file in a loop:
ffmpeg -nostdin -loglevel fatal -ss 15 -i "${filename}" -frames:v 1 "${out1}"
ffmpeg -nostdin -loglevel fatal -sseof -15 -i "${filename}" -frames:v 1 "${out2}"
This extracts a frame 15s in and another frame 15s from the end. For N video files I need 2N ffmpeg calls. I experimented with -vf select
, as was asked here, but this was much slower, especially with the requirement to select frames from the beginning and from the end. Also, I am already using GNU parallel which makes a big difference.
Performance is actually not too bad. But my question is, can this be improved further? I am hoping for a way to
- to extract both frames in one ffmpeg call (faster than two separate calls), or
- to feed ffmpeg more than one file per call (to reduce process startup overhead)