include_thumbnails="$0"
gen_thumb(){
- local file="$1" thumb="$2" tmp="${TMPDIR:-/tmp}/serve0tmp_$$/" lenght
+ local file="$1" thumb="$2" tmp="${TMPDIR:-/tmp}/serve0tmp_$$/" lenght n
if [ "${file%.part}" = "${file}" -a ! -s "$thumb" -a -s "$file" ] && mkdir "$tmp"; then
- length="$(
- ffprobe -show_entries stream=duration "$file" 2>&- \
- | sed -nE 's;duration=([0-9\.]+)\r?$;\1;p;'
- )"
+ length="$( ffprobe -show_entries stream=duration "$file" 2>&- )"
+ length="${length#*duration=}" length="${length%%${BR}*}" length="${length%.*}"
- ffmpeg -nostdin -y -i "$file" -vf scale=320:-2,fps=10/$length "$tmp/thumb_%02d.jpg" 2>&-
- montage "$tmp/thumb_0"[1-9].jpg "$tmp/thumb_10.jpg" \
+ # ffmpeg -nostdin -y -i "$file" -vf fps=11/$length,scale=320:-2 -frames 10 "$tmp/thumb_%02d.jpg" 2>&-
+
+ for n in 1 2 3 4 5 6 7 8 9 10; do
+ ffmpeg -nostdin -y -ss "$((n * length / 11))" -i "$file" -frames 1 "$tmp/thumb_$((n - 1)).jpg" 2>&-
+ done
+
+ montage "$tmp"/thumb_[0-9].jpg \
-tile 10x1 -geometry 320x180+0+0 \
-interlace line -quality 85 "$thumb"
rm -r -- "${tmp}"