Skip to content

Instantly share code, notes, and snippets.

@PVince81
Created January 11, 2021 09:26
Show Gist options
  • Save PVince81/79d0c73ac06ff508a97e68c8d0f0d7fc to your computer and use it in GitHub Desktop.
Save PVince81/79d0c73ac06ff508a97e68c8d0f0d7fc to your computer and use it in GitHub Desktop.
nc_export_pics
#!/bin/bash
shopt -s nullglob
INPUT_DIR="$1"
OUTPUT_DIR="$INPUT_DIR"/out
TARGET_DIR="$2"
function syntax
{
echo "nc_export_pics /path/to/input /path/to/output" >&2
echo
}
if ! test -d "$INPUT_DIR"; then
echo "Missing input dir $INPUT_DIR" >&2
syntax
exit 1
fi
if ! test -d "$TARGET_DIR"; then
echo "Missing target dir $TARGET_DIR" >&2
syntax
exit 1
fi
TARGET_DIR=$(realpath "$TARGET_DIR")
mkdir -p "$OUTPUT_DIR"
cd "$INPUT_DIR"
echo Stripping geo tags from pictures
for I in *.jpg *.JPG
do
echo "Processing $I"
exiftool -geotag= -categories= -tagslist= -lastkeywordxmp= -hierarchicalsubject= -catalogsets= -subject= -keywords= "$I" -picklabel= -colorlabel= -label= -o "$OUTPUT_DIR" && mv "$OUTPUT_DIR/$I" "$TARGET_DIR"
done
echo Optimizing mp4 for web
for I in *.mp4 *.MP4
do
echo "Processing $I"
ffmpeg -i "$I" -movflags faststart -acodec copy -vcodec copy "$OUTPUT_DIR/$I" && mv "$OUTPUT_DIR/$I" "$TARGET_DIR"
done
echo Converting MOV to webm
for I in *.MOV
do
echo "Processing $I"
OUT_FILE="$OUTPUT_DIR/${I%.MOV}".webm
ffmpeg -i "$I" -c:v libvpx-vp9 -crf 18 -b:v 0 -c:a libvorbis "$OUT_FILE" && mv "$OUT_FILE" "$TARGET_DIR"
done
echo Moving everything else
mv *.webm *.WEBM "$TARGET_DIR"
rmdir "$OUTPUT_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment