- Rename files with media creation date with file creation date as fallback.
exiftool -d '%Y-%m-%d_%H.%M.%S%%-2c%.%%e' '-filename<fileModifyDate' '-filename<CreateDate' '-filename<MediaCreateDate' '-filename<DateTimeOriginal' *.EXTENSION
- Fix other Data tags for instagram videos. Used after
Fix video media create date hour (timezone)
exiftool -overwrite_original_in_place '-TrackCreateDate<MediaCreateDate' '-TrackModifyDate<MediaCreateDate' '-MediaModifyDate<MediaCreateDate' *.mp4
exiftool -overwrite_original_in_place '-VideoDates<FileModifyDate' *.mp4
#!/bin/bash
for f in *;
do mv "$f" "$f.tmp";
mv "$f.tmp" "`echo $f | tr "[:upper:]" "[:lower:]"`";
done;
- Resize imagens bigger than ...
mogrify -thumbnail 'MAXWIDTHxMAXHEIGHT>' *
- Lossless optimization of png/jpg (strips metadata) (source)
find . -iname '*.png' -print0 -exec optipng -o7 -strip all "{}" \;
find -E . -iregex '.*\.(jpg|jpeg|jpe|jif|jfif|jfi)$' -exec jpegoptim --all-progressive --strip-all --strip-iptc --strip-icc "{}" \;
Notes
- STRIPS METADATA
- optipng version older than 7 doesn’t work with -strip all, remove it from command in this case.
- For fast png optimization change -o7 to -o2, compress ratio will be just a bit worse, but it will work more faster
- Jpeg optimization is lossless, but you can use –max=90 to change compress ratio (100 for lossless compress, less is better compress but worse quality.
Note: if using this .exiftool_config, you can switch AllDates
for PhotoDates
or VideoDates
exiftool -overwrite_original_in_place '-AllDates-=2:0:0' '-MediaCreateDate-=2:0:0' '-MediaModifyDate-=2:0:0' *.mp4
- Set image creation dates based on filename (example is for images generated by instagram stories)
Images generated by instagram:
exiftool -overwrite_original_in_place '-AllDates<${Filename;s/IMG_(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})/$1:$2:$3 $4:$5:$6/}' *.EXTENSION
Images generated by dropbox camera upload:
exiftool -overwrite_original_in_place '-AllDates<${Filename;s/(\d{4})-(\d{2})-(\d{2})_(\d{2})\.(\d{2})\.(\d{2})/$1:$2:$3 $4:$5:$6/}' *.EXTENSION
- Copy metadata from one video to another (source)
ffmpeg -i in.mp4 -i out.mp4 -map 1 -map_metadata 0 -c copy fixed.mp4
- H.264 batch encoding (not tested THAT much)
find . -type f \( -iname '*.mp4' -o -iname '*.mov' -o -iname '*.mkv' -o -iname '*.m4v' \) -not -path './ffmpeg-output/*' -exec bash -c '
SRC_PATH=$1;
TARGET_DIR="$(pwd)/ffmpeg-output/$(dirname "$1")/";
TARGET_FILENAME="$(basename "${1%.*}").mp4";
TARGET_PATH="$TARGET_DIR$TARGET_FILENAME";
mkdir -p "$TARGET_DIR";
ffmpeg \
-i "$1" \
-preset slow \
-c:v libx264 \
-crf 19\
-map_metadata 0 \
"$TARGET_PATH" \
;
touch -r "$SRC_PATH" "$TARGET_PATH";
echo -ne "\007";
' _ '{}' \;
If you want to convert 1080p to 720p, just add a -vf scale=-1:720 \
parameter to the above ffmpeg
call.