Python Forum
Python convert duration in seconds to hh:mm:ss:ms
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python convert duration in seconds to hh:mm:ss:ms
#1
Hi. I want read audio file duration in hh:mm:ss:ms, so i use mutagen and i obtain duration time in seconds. Next i try convert it to final format but i have error ValueError: Invalid format string.


import mutagen
import random
import time
import sys
import mad
from datetime import datetime
from mutagen.mp3 import MP3
import glob,os
audio = MP3("example.mp3")
len = time.strftime('%H:%M:%S.%f', time.gmtime(audio.info.length))
print (len)enter code here
Reply


Messages In This Thread
Python convert duration in seconds to hh:mm:ss:ms - by LeeJacek - Dec-14-2017, 02:51 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020