From 5e3b2e830bfa3084bfc9c0d5fee0f47cef5f5c7e Mon Sep 17 00:00:00 2001 From: shockrah Date: Wed, 20 Oct 2021 21:28:02 -0700 Subject: [PATCH] + Tree clone script --- scripts/tn-tree-clone.sh | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/tn-tree-clone.sh diff --git a/scripts/tn-tree-clone.sh b/scripts/tn-tree-clone.sh new file mode 100644 index 0000000..67cce30 --- /dev/null +++ b/scripts/tn-tree-clone.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +# This script basically clones the tree structure of the videos directory +# At the same time it will generate thumbnails for each video + +vids="$1" # root dir for videos that we're going to clone +thumbs="$2" # root dir for thumbnails we'll create + +_show_usage() { +cat << EOF +Generate thumbnails for a whole tree of clips +Usage: + $0 CLIPS_ROOT_PATH TARGET_ROOT +EOF +exit 1 +} + +if [ -z "$vids" ];then + echo 'Missing root video directory!' + _show_usage +fi + +if [ -z "$thumbs" ];then + echo 'Missing target thumbnails directory' + _show_usage +fi + +echo Cloning directory structure +pushd "$vids" > /dev/null + find . -type d | while read f; do + mkdir -p "$thumbs/$f" + done +popd > /dev/null + +echo Generating thumbnails +thumbs="`realpath "$thumbs"`" +pushd "$vids" > /dev/null + find . -type f -name '*.mkv' -o -name '*.mp4' -o -name '*.webm' | while read f; do + if="`realpath "${vids}/$f"`" + of="`realpath "${thumbs}/$f"`" + # Make sure only errors pop up here + ffmpeg -hide_banner -loglevel error \ + -y -ss 00:00:01 -i "$if" -frames:v 1 "$of.jpg" > /dev/null + echo $of + done +popd > /dev/null \ No newline at end of file