video thumbnails in preview-tui

This commit is contained in:
johnnybash 2020-12-21 16:24:18 +01:00
parent 66a8b69426
commit a918a59856

View file

@ -26,6 +26,10 @@
# To use: # To use:
# 1. install pistol # 1. install pistol
# 2. set/export $USE_PISTOL as 1 # 2. set/export $USE_PISTOL as 1
# - optional: ffmpegthumbnailer for video thumbnails (https://github.com/dirkvdb/ffmpegthumbnailer).
# To use:
# 1. install ffmpegthumbnailer
# 2. set/export USE_VIDEOTHUMB as 1
# #
# Usage: # Usage:
# You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG, # You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG,
@ -63,6 +67,7 @@ SPLIT="$SPLIT" # you can set a permanent split here
TERMINAL="$TERMINAL" # same goes for the terminal TERMINAL="$TERMINAL" # same goes for the terminal
USE_SCOPE="${USE_SCOPE:-0}" USE_SCOPE="${USE_SCOPE:-0}"
USE_PISTOL="${USE_PISTOL:-0}" USE_PISTOL="${USE_PISTOL:-0}"
USE_VIDEOTHUMB="${USE_VIDEOTHUMB:-0}"
PAGER="${PAGER:-less -R}" PAGER="${PAGER:-less -R}"
[ "$PAGER" = "most" ] && PAGER="less -R" [ "$PAGER" = "most" ] && PAGER="less -R"
@ -163,6 +168,19 @@ preview_file () {
else else
fifo_pager print_bin_info "$1" fifo_pager print_bin_info "$1"
fi fi
elif [ "${mimetype%%/*}" = "video" ] && [ "$USE_VIDEOTHUMB" -ne 0 ] && exists ffmpegthumbnailer; then
ffmpegthumbnailer -s 0 -i "$1" -o "/tmp/videothumb.png"
if [ "$TERMINAL" = "kitty" ]; then
# Kitty terminal users can use the native image preview method.
kitty +kitten icat --silent --transfer-mode=stream --stdin=no \
"/tmp/videothumb.png" &
elif exists catimg; then
catimg "/tmp/videothumb.png"
elif exists viu; then
viu -t "/tmp/videothumb.png"
else
fifo_pager print_bin_info "$1"
fi
elif [ "$mimetype" = "application/zip" ] ; then elif [ "$mimetype" = "application/zip" ] ; then
fifo_pager unzip -l "$1" fifo_pager unzip -l "$1"
elif [ "$ext" = "gz" ] || [ "$ext" = "bz2" ] ; then elif [ "$ext" = "gz" ] || [ "$ext" = "bz2" ] ; then