1

When I use exiftool to get the duration of an audio file, if the file is over 24 hours I get “1 day 1:23:45” instead of 25:23:45. Sometimes I get “approx 13:17:23”.

Is it possible to tell exiftool to only return HH:MM:SS regardless of how long the file actually is and if it thinks the time is approximate or not (I can strip out the approximate if I have to, but if there’s a way to specify the output format I can’t find it)?

exiftool -d "%H:%M:%S" -Duration Audiobook.m4a
Duration                        : 1 days 1:17:20

This works, assuming there its no way to get exiftool to output the hours:

    if [[ $DURA == *"days"* ]]; then
        EXIF=$(exiftool -duration# "$FILE")
        SEC=$(awk -F": " '/Dura/ {print $2}' <<<"$EXIF" |awk -F'.' '{print $1}')
        HOR=$(($SEC / 3600))
        MIN=$(($SEC % 3600/60))
        SES=$(($SEC % 60))
        DURA="$HOR:$MIN:$SES"
     fi
lbutlr
  • 414
  • 6
  • 18
  • You could use `-duration#` instead to get the duration in pure seconds... – Mark Setchell May 19 '21 at 22:25
  • duration# shows seconds and fractional seconds, not what I want, but better than what I have. – lbutlr May 20 '21 at 00:25
  • The [`-d` (`-dateFormat`) option](https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat) only affects date/time tags. Tags which are timestamps for a specific moment. To change the duration output in exiftool, you would have to make some Perl code to do what you want and make a user-defined tag. – StarGeek May 21 '21 at 14:30

1 Answers1

0

Answer: no way to do this in efixtool, so work around somehow (I chose bash script, but whatever).

lbutlr
  • 414
  • 6
  • 18
  • If this is the answer, please make sure that future readers can easily find and see all that they need to solve your problem here. Thank you. – Mark Setchell May 26 '21 at 00:00
  • I included my shell workaround in the original post. I didn’t think it was worth reposting that. – lbutlr May 26 '21 at 11:43