Created
April 10, 2022 11:51
-
-
Save afriza/ad45040bf620df0f8b6968b89b3ede1a to your computer and use it in GitHub Desktop.
Get video duration using ffprobe from ffmpeg suite
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
#! /bin/sh | |
DIR=${1:-"."} | |
find "$DIR" -type f -iname "*.mp4" -print0 | sort -z | xargs -r0 -I{} duration.sh "{}" |
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
#! /bin/sh | |
FILE=$1 | |
if [ -z "$FILE" ]; then | |
echo file paramater is required. | |
exit 1 | |
fi | |
# remove -sexagesimal to get duration in seconds | |
#DURATION=$(ffprobe -i "$FILE" -show_entries format=duration -v fatal -of csv=p=0) | |
DURATION=$(ffprobe -i "$FILE" -show_entries format=duration -v fatal -of csv=p=0 -sexagesimal) | |
echo "$DURATION $FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment