hpr-tools/workflow/duration.bash

31 lines
1010 B
Bash
Raw Normal View History

2024-11-03 16:07:14 +00:00
#!/bin/bash
# Copyright Ken Fallon - Released into the public domain. http://creativecommons.org/publicdomain/ ]
if [ -f "${1}" ]
then
mediainfo --Output=XML --Full "${1}" | xmlstarlet sel -T -t -m '/_:MediaInfo/_:media/_:track[@type="Audio"]' -v '_:Duration' -n | sed 's/0$//g'
exit 0
fi
find ./ -type f | grep -E -v '/sponsor-anhonesthost.com-hpr15.flac|/outro.flac|/intro.flac|/sponsor-archive.org.flac' | while read mediafile
do
if [ "$( file "${mediafile}" | grep -c audio )" == "0" ]
then
continue
fi
duration=$( mediainfo --full --Output=XML "${mediafile}" | xmlstarlet sel -T -t -m "_:MediaInfo/_:media/_:track[@type='Audio']/_:Duration[1]" -v "." -n - | sed 's/0$//g')
if [ "${duration}" != "" ]
then
echo "${mediafile}: ${duration}"
continue
fi
duration=$( /bin/date -ud "1970-01-01 $( ffprobe -i "${mediafile}" 2>&1| awk -F ': |, ' '/Duration:/ { print $2 }' )" +%s )
if [ "${duration}" != 0 ]
then
echo "${mediafile}: ${duration}"
continue
fi
done