Last active
December 29, 2015 15:59
-
-
Save oparrish/7694368 to your computer and use it in GitHub Desktop.
Output the duration for an M4A
This file contains hidden or 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
#!/usr/local/bin/python | |
import sys | |
from mutagen.mp4 import MP4 | |
m4a_file = sys.argv[1] | |
m4a = MP4(m4a_file) | |
length_secs = m4a.info.length | |
hours = int(length_secs / 60 / 60) | |
minutes = int(length_secs / 60) - hours * 60 | |
seconds = int(length_secs - minutes * 60 - hours * 3600) | |
print("{:02}:{:02}:{:02}".format(hours,minutes,seconds)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment