+ Tree clone script
This commit is contained in:
parent
71407b9202
commit
5e3b2e830b
48
scripts/tn-tree-clone.sh
Normal file
48
scripts/tn-tree-clone.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user