Last active
January 7, 2021 06:51
-
-
Save sbibauw/b3283367cadf4486b43dd6a7f9c68b58 to your computer and use it in GitHub Desktop.
Archiving and optimization of local Zoom recordings and chat logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bin/sh | |
# What it does: | |
# - Chat logs archived in a zoom_archive subfolder with the date and name of the meeting in the filename | |
# - Video recordings resized down (to a maximum width of 980 px) and renamed (date and name of meeting + number) | |
# - All other files (playlists, audio recordings) moved to the trash | |
cd ~/Zoom | |
# For each subfolder | |
for D in */; do | |
# Archiving of chat logs | |
if test -f "${D}meeting_saved_chat.txt"; then | |
cat ${D}meeting_saved_chat* >"$(basename $D) chat.txt" | |
mv "$(basename $D) chat.txt" ~/Zoom/zoom_archive | |
trash ${D}meeting_saved_chat* | |
fi | |
# Archiving of closed captions | |
if test -f "${D}closed_caption.txt"; then | |
cat ${D}closed_caption* >"$(basename $D) closed_caption.txt" | |
mv "$(basename $D) closed_caption.txt" ~/Zoom/zoom_archive | |
trash ${D}closed_caption* | |
fi | |
# Archiving of screenshots | |
n=1 | |
for i in ${D}*.png; do | |
name="$(basename $D) screenshot$((n++)).jpg" | |
sips -s format jpeg -s formatOptions 85 "${i}" --out "${name}" | |
sips -Z 1280 "${name}" | |
imageoptim "${name}" | |
mv "${name}" ~/Zoom/zoom_archive | |
trash "${i}" | |
done | |
done | |
# Removing unnecessary files | |
trash ~/Zoom/**/*.m3u | |
trash ~/Zoom/**/*.m4a | |
trash ~/Zoom/**/chat.txt | |
# Removing all initial video recordings smaller than 1 MB (= shorter than 20-25 seconds) | |
find ~/Zoom -name 'zoom_*.mp4' -type f -size -1M -print0 | xargs -0 trash | |
# Reducing MP4 files in size and renaming them | |
for video in ~/Zoom/**/zoom_[0-9].mp4; do | |
newname="$(dirname "$video") $(basename "$video" .mp4 | sed -e 's/zoom_//').mp4" | |
ffmpeg -i "$video" -c:v libx264 -vf scale=w=980:h=-1:force_original_aspect_ratio=decrease "$newname" | |
if find "$newname" -type f -size +1c 2>/dev/null | grep -q .; then | |
trash "$video" | |
else | |
trash "$newname" | |
fi | |
done | |
for video in ~/Zoom/**/zoom_[0-9].mp4; do | |
newname="$(dirname "$video") $(basename "$video" .mp4 | sed -e 's/zoom_//').mp4" | |
ffmpeg -i "$video" -c:v libx264 -vf scale=w=960:h=-1:force_original_aspect_ratio=decrease "$newname" | |
if find "$newname" -type f -size +1c 2>/dev/null | grep -q .; then | |
trash "$video" | |
else | |
trash "$newname" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment