Last active
April 22, 2024 17:23
-
-
Save melissachang/6bb1d705f442d4b2694d05c8aa344090 to your computer and use it in GitHub Desktop.
Create sidecar images for videos, for storing metadata
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/bash | |
# Don't proceed if there are no files with a particular extension. https://stackoverflow.com/a/41139446 | |
shopt -s nullglob | |
# Match MP4 in addition to mp4 | |
shopt -s nocaseglob | |
for video_file in *.{mp4,mov} ; do | |
sidecar_file=$(echo $video_file | sed 's/\(.*\.\).*/\1jpg/' ) | |
echo "Exporting sidecar for ${video_file}: ${sidecar_file}" | |
ffmpeg -ss 00:00:00 -i "${video_file}" -vframes 1 -y "${sidecar_file}" -loglevel error | |
# Fix video Create Date. Pixel 5 videos (but not photos) have incorrect date. This way, if | |
# I sort by Create Date in Lightroom, video will be in right place. | |
# PST - 8 - 1st Sun in Nov to 2nd Sun in Mar | |
# PDT - 7 - 2nd Sun in Mar to 1st Sun in Nov | |
exiftool "-AllDates-=7" -overwrite_original -quiet -api LargeFileSupport=1 "${video_file}" | |
# Copy Create Date from video to sidecar. -ee just to hide Warning. | |
exiftool -overwrite_original -quiet -ee -tagsfromfile "$video_file" -api LargeFileSupport=1 "$sidecar_file" | |
done | |
say done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment