我用这段代码做到了...
testApp="avconv"; which $testApp >/dev/null 2>&1 || { echo "$testApp not found, try 'apt-get install libav -y'"; exit 1; }
for f in *.mp4 ; do f2=${f%.*}; r1=$((RANDOM%300+30)); [ -f "$f2.jpg" ] || { avconv -ss $r1 -i "$f" -vsync 1 -r 1 -an -y -vframes 1 -timelimit 1 -vf scale='-1':'640',crop=640:480 "$f2.jpg"; }; done
相同的代码
testApp="avconv"; which $testApp >/dev/null 2>&1 || { echo "$testApp not found, try 'apt-get install libav -y'"; exit 1; }
for f in *.mp4 ; do
f2=${f%.*}; r1=$((RANDOM%300+30))
[ -f "$f2.jpg" ] || {
avconv -ss $r1 -i "$f" -vsync 1 -r 1 -an -y -vframes 1 -timelimit 1 -vf scale='-1':'640',crop=640:480 "$f2.jpg"
}
done
f=文件名
f2=不带扩展名的文件名
r1=随机整数,介于 20-300 之间,这是快照的时间,以秒为单位