Skip to content

Instantly share code, notes, and snippets.

@bsidhom
Created March 14, 2023 04:22
Show Gist options
  • Save bsidhom/8f7ed04ca3c4e163ed96d8cdd30aac1d to your computer and use it in GitHub Desktop.
Save bsidhom/8f7ed04ca3c4e163ed96d8cdd30aac1d to your computer and use it in GitHub Desktop.
Print video creation time of MP4 files
#!/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