#!/usr/bin/env python3
from sys import stderr, argv, exit
import subprocess

def hms(inp):
    m,s = divmod(inp,60)
    h,m = divmod(m,60)
    return f"{str(int(h)).zfill(2)}:{str(int(m)).zfill(2)}:{str(round(s,2)).zfill(2)}"
#    return ":".join(map(str,(int(h),int(m),round(s,2))))

def get_video_duration(fileloc) :
    command = ['ffprobe',
               '-v', 'fatal',
               '-show_entries', 'stream=duration',
               '-of', 'default=noprint_wrappers=1:nokey=1',
               fileloc, '-sexagesimal']
    ffmpeg = subprocess.Popen(command, stderr=subprocess.PIPE ,stdout = subprocess.PIPE )
    out, err = ffmpeg.communicate()
    if(err) : print(err)
    out = out.decode('utf-8').strip()
    return map(float,out.split(":"))

def main():
    tot = 0.0
    for fn in argv[1:]:
        h,m,s = get_video_duration(fn)
        tot += h*60*60 + m*60 + s
        print(f"{hms(tot)}", end="\r", file=stderr)
    print(hms(tot))
    return 0

if __name__ == "__main__":
    try:
        exit(main())
    except KeyboardInterrupt:
        exit(127)