Created
July 17, 2023 19:23
-
-
Save farzadhallaji/bbea1c35d969170f9c0fbfbf499d9742 to your computer and use it in GitHub Desktop.
Total duration of all videos
This file contains 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
import os | |
from moviepy.editor import VideoFileClip | |
folder_path = '/home/ri/Desktop/TFL/ahmadian' # Replace with the path to your folder | |
total_duration = 0 | |
for file in os.listdir(folder_path): | |
if file.endswith('.webm'): # Adjust the file extension if necessary | |
file_path = os.path.join(folder_path, file) | |
video = VideoFileClip(file_path) | |
duration = video.duration | |
total_duration += duration | |
video.close() | |
print("Total duration of all videos:", total_duration) | |
total_duration_minutes = total_duration / 60 | |
print("Total duration of all videos (in minutes):", total_duration_minutes) | |
total_duration_hours = total_duration / 3600 | |
print("Total duration of all videos (in hours):", total_duration_hours) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment