# Calculate total duration, average, and median if there are video files
if video_durations:
total_duration = sum(video_durations)
average_duration = total_duration / len(video_durations)
median_duration = statistics.median(video_durations)
# Write results to a text file
with open("video_duration_stats.txt", "w") as f:
f.write(f"Combined duration of all video files: {format_duration(total_duration)}\n")
f.write(f"Average duration of video files: {format_duration(average_duration)}\n")
f.write(f"Median duration of video files: {format_duration(median_duration)}\n")
print("Video duration stats have been saved to 'video_duration_stats.txt'")
else:
print("No video files found in the current directory.")
You are viewing a single comment's thread from: