Im currently working on a school project which require me to handle mpeg-2 files. Currently, i am using mutagen to extract the metadata for my mpeg file. However when i try to get the metadata of title, artist, album, etc. It show me with a following error. [Python Code Appreciated]
Below if my output :
mutagen.id3.ID3NoHeaderError: 'media/test.mpeg' doesn't start with ID3 Tag
It shows that there was no container so called to hold the ID3 Tag, do anyone care to explain me why it is so?
It works out perfectly when i am working with mp3 file but not with mpeg.
Below is a portion of my code (hardcode):
from mutagen.id3 import ID3
file = "media/test.mpeg"
audio = ID3(file)
print "Artist: %s" % audio['TPE1'].text[0]
print "Track: %s" % audio["TIT2"].text[0]
print "Release Year: %s" % audio["TDRC"].text[0]
The second problem is that when i try to get the duration of the mpeg file, it return me with a wrong duration.
File duration = 21 second
when i run my code it show a duration of : 1124.5705721 second
Below is a portion of my code (hardcode):
import mutagen
from mutagen.mp3 import MP3
from mutagen.mp3 import MPEGInfo
file = "media/test.mpeg"
audio = MP3(file)
print audio.info.length