Created
March 14, 2023 04:22
-
-
Save bsidhom/8f7ed04ca3c4e163ed96d8cdd30aac1d to your computer and use it in GitHub Desktop.
Print video creation time of MP4 files
This file contains hidden or 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
#!/usr/bin/env bash | |
set -euo pipefail | |
readonly TIME_ZONE="${TIME_ZONE:-America/Los_Angeles}" | |
function main() { | |
local file="$1" | |
local timestamp | |
timestamp="$(extract_timestamp "$file")" | |
env TZ="$TIME_ZONE" gdate -Is --date "$timestamp" | |
} | |
function extract_timestamp() { | |
local file="$1" | |
ffprobe_json "$file" | jq_extract_timestamp | |
} | |
function ffprobe_json() { | |
local file="$1" | |
ffprobe -v quiet -print_format json -show_format -show_streams "$file" | |
} | |
function jq_extract_timestamp() { | |
jq -r '.format.tags.creation_time' | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment