Reputation: 9602
I get a screenshot from a remote video file using ffmpeg with a command like ffmpeg -ss $TIME -i $URL -frames:v 1 -filter:v $FILTER file.jpg
(-ss
comes before -i
for fast seeking https://trac.ffmpeg.org/wiki/Seeking). $FILTER
is how I want to transform the screenshot, like cropping/resizing. In this case it's "crop=iw-5:ih-5, scale=100:100:force_original_aspect_ratio=increase, crop=100:100"
)
If I want to get 3 screenshots, at 3 seconds, 5 seconds, and 14 seconds, I need to run this command 3 separate times, passing 3, 5, and 14 as $TIME
. But is it possible to run the command once but have it output multiple screenshot files for the different times?
And would ffmpeg do that in a way where it would make the round-trip remote request just 1 time instead of 3? In that case it would be more efficient. If not, then maybe it's better to make the 3 requests separately since I could do it in parallel.
Upvotes: 0
Views: 3037
Reputation: 31209
For screenshots at equal intervals see the wiki.
For specific timestamps you can do it in one pass using the select filter:
ffmpeg -i <input> -filter:v "select='0-eq(t,3)-eq(t,5)-eq(t,14)',<other filters>" -vsync vfr file%01d.png
where t
is the presentation timestamp in seconds.
You could also search for I-frames in specific intervals using between
and pict_type
PICT_TYPE_I
.
Upvotes: 3