From 2168a8de63aa52ea4d031b766bd8dd662c00a279 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 2 Oct 2021 22:24:04 +0200 Subject: [PATCH] grab thumbnails by fast seeking --- page_video.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/page_video.sh b/page_video.sh index 0a1f275..6d3a8eb 100644 --- a/page_video.sh +++ b/page_video.sh @@ -23,7 +23,7 @@ update_video(){ hits descr_cache futureuse local ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ DESCR_CACHE FUTUREUSE - local arg video thumb + local arg video thumb cnt video="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4" thumb="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg" @@ -42,11 +42,17 @@ update_video(){ resy="${arg#*height=}"; resy="${resy%%${BR}*}" length="${arg#*duration=}"; length="${length%%${BR}*}" fi - if [ "$length" -a ! "${thumb}" -nt "${video}" ]; then - ffmpeg -nostdin -y -i "$video" -vf scale=320:-2,fps=10/${length} "${thumb%.jpg}_%02d.jpg" - montage "${thumb%.jpg}_"[01][0-9].jpg -tile 10x1 -geometry 320x180+0+0 -quality 85 "${thumb}" - rm -- "${thumb%.jpg}_"[01][0-9].jpg - fi 2>&- + if [ "${length%.*}" -a ! "${thumb}" -nt "${video}" ]; then + for cnt in 1 2 3 4 5 6 7 8 9 10; do + ffmpeg -nostdin -y -ss "$((cnt * ${length%.*} / 11))" -i "$video" \ + -frames 1 "${thumb%.jpg}_$((cnt - 1)).jpg" + done 2>&- + montage "${thumb%.jpg}"_[0-9].jpg \ + -background "#000000" \ + -tile 10x1 -geometry 320x180+0+0 \ + -interlace line -quality 85 "${thumb}" + rm -- "${thumb%.jpg}"_[0-9].jpg + fi if LOCK "$vid_db"; then while read -r ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ -- 2.39.2