Reputation: 2344
I have bunch of videos which are rather long, so I take screenshots of 10th second (-ss 00:00:10
). Sometimes videos are very short, like 5 seconds, and -ss 00:00:10
fails.
I don't have an option to compute video size as don't have an option to download them whole (videos are hosted on S3 and used as streams through CloudFront).
Maybe there are some built-in options that I overlooked?
What I really don't want to do is shorten -ss
option gradually on fails so it would be the last resort.
Upvotes: 0
Views: 293
Reputation: 31227
One liner:
ffprobe -show_entries format=filename,duration -of default=noprint_wrappers=1:nokey=1 /path/to/input/file -loglevel 0 | awk 'BEGIN {RS="";FS="\n"}{system("ffmpeg -ss "$2/2" -i "$1" -vframes 1 out.png") }'
meaning:
use ffprobe
to get the file duration in seconds then pipe to awk
and execute the frame extraction ffmpeg
command using a seek time equal to duration/2
Upvotes: 2