Created
May 11, 2016 03:56
-
-
Save yoosefi/66d9a58466fb9e8bf5a8467fc11f470e to your computer and use it in GitHub Desktop.
sets a video's encode date by using the file's mtime
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 | |
# sets a video's encode date by using the file's mtime | |
# requires mediainfo and ffmpeg | |
# see also the inverse of this script: "mtime-from-encode-date.sh" | |
# https://gist.github.com/yoosefi/3d5841e0c2b71edf02eec0730249128f | |
set -eu | |
for each in "$@"; do | |
x=($(mediainfo "${each}" | grep 'Encoded date')) | |
# only remux if the date is bogus | |
if [[ "${x}" == "" || "${x[4]}" =~ ^19[0-8].* ]]; then | |
MTIME=$(date --iso-8601=seconds -r "${each}") | |
mv "${each}" "${each}.old" | |
TZ=UTC ffmpeg -i "${each}.old" -c copy -map_metadata 0 -metadata creation_time="${MTIME}" "${each}" | |
touch -d "${MTIME}" "${each}" | |
rm "${each}.old" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment