X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=thumbnail.sh;h=143077640c049f1c35dbfbc0584607855cf6986a;hp=4a6f828b846f7a213830ff8361afafb79dac0707;hb=HEAD;hpb=db0868f2e033589fcc6e61ae84cce7d4e3766933 diff --git a/thumbnail.sh b/thumbnail.sh old mode 100644 new mode 100755 index 4a6f828..f13ec1c --- a/thumbnail.sh +++ b/thumbnail.sh @@ -4,19 +4,23 @@ include_thumbnails="$0" gen_thumb(){ - local file="$1" thumb="$2" tmp="${TMPDIR:-/tmp}/serve0tmp_$$/" lenght n + local file="$1" thumb="$2" bgcolor="${3:-#000000}" + local 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>&- )" + length="$( ffprobe -show_entries format=duration "$file" 2>&- )" length="${length#*duration=}" length="${length%%${BR}*}" length="${length%.*}" # 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>&- + nice -4 \ + ffmpeg -nostdin -y -ss "$((n * length / 11))" -i "$file" -frames 1 -filter scale=640:-2 "$tmp/thumb_$((n - 1)).jpg" 2>&- done + nice -4 \ montage "$tmp"/thumb_[0-9].jpg \ + -background "$bgcolor" \ -tile 10x1 -geometry 320x180+0+0 \ -interlace line -quality 85 "$thumb" rm -r -- "${tmp}"