-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path34-video-duration.sh
More file actions
16 lines (13 loc) · 685 Bytes
/
Copy path34-video-duration.sh
File metadata and controls
16 lines (13 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
total_duration=0
for file in ./*.mp4; do
if [ -f "$file" ]; then
echo "File: $file"
duration=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file" 2>/dev/null)
total_duration=$(echo "$total_duration + $duration" | bc)
fi
done
# Calculate minutes, seconds, and fractional seconds separately
total_minutes=$(bc <<< "scale=0; $total_duration / 60")
total_seconds=$(bc <<< "scale=0; $total_duration % 60")
total_fractional_seconds=$(bc <<< "scale=6; $total_duration - ($total_minutes * 60) - $total_seconds")
echo "Total Duration: $total_minutes minutes $total_seconds seconds $total_fractional_seconds seconds"