6

A folder of 10 video files, how to get the total duration of them? BTW, I have tried (Command+Control+I) and it doesn’t show the total duration.

fixer1234
  • 28,064
M. A.
  • 109

2 Answers2

9

You can also open all of the files in VLC. It will play the videos automatically, but press stop in the lower left (the square symbol) and it will show you the playlist. At the top of the playlist it will have the total duration. If you enable the correct columns (right click on a column header and check the appropriate boxes), it will give the name, file size, and duration for the individual files, as well.

Additionally, VLC is an amazingly fully-featured video player that supports every format you will ever encounter, and then plenty more. It is also cross-platform (working on Linux as well as Windows).

0

Use Python script solved this problem.

# -*- coding: utf-8 -*-

"""

pip install --upgrade setuptools
pip install moviepy

usage:
python compute_duration.py --path ~/Movies/ --type .mp4
"""

import os
import datetime
import argparse
from moviepy.editor import VideoFileClip


def main():
    parser = argparse.ArgumentParser(
        description='Compute Total Time of a Series of Videos')
    parser.add_argument("--path", metavar="PATH", default=".",
                        help="the root path of the videos(default: .)")
    parser.add_argument("--type", metavar="TYPE", default=".mkv",
                        help="the type of the videos(default: .mkv)")
    args = parser.parse_args()
    filelist = []
    for a, b, c in os.walk(args.path):
        for name in c:
            fname = os.path.join(a, name)
            if fname.endswith(args.type):
                filelist.append(fname)
    ftime = 0.0
    for file in sorted(filelist):
        clip = VideoFileClip(file)
        print("{}: {}".format(file, clip.duration))
        ftime += clip.duration
    print("%d seconds: " % ftime, str(datetime.timedelta(seconds=ftime)))


if __name__ == "__main__":
    main()

Pegasus
  • 101