Showing posts with label media content testing. Show all posts
Showing posts with label media content testing. Show all posts

Wednesday, December 3, 2014

AtomicParsley and getID3


AtomicParsley is a lightweight command line program for reading, parsing and setting metadata into MPEG-4 files supporting these styles of metadata:

  •     iTunes-style metadata into .mp4, .m4a, .m4p, .m4v, .m4b files
  •    3gp-style assets (3GPP TS 26.444 version 6.4.0 Release 6 specification conforming) in 3GPP, 3GPP2, MobileMP4 & derivatives
  •     ISO copyright notices at movie & track level for MPEG-4 & derivative files
  •     uuid private user extension text & file embedding for MPEG-4 & derivative files

getID3() is a PHP script that extracts useful information from MP3s & other multimedia file formats

MP4 container details

With thanks - Source!!

Diagram shows how boxes or atoms within an MP4 file might fit inside each other

Tuesday, December 2, 2014

python hachoir Library for Media Metadata Extraction

In case if you want to extract metadata from a media file, python's hachoir library will be a handy tool for same. You may find the initial start-up material from here



You need to download following three packages:

  • hachoir_core
  • hachoir_parser
  • hachoir_metadata


running "setup.py install" command on windows will automatically put these libraries inside python Libs site-packages folder so that they immediately become available and you may run the command like "from hachoir_core.error import HachoirError" on python terminal



Download and install everything from here:



Copy following code in a python file and run it to see in action:

from hachoir_core.error import HachoirError
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
from hachoir_core.tools import makePrintable
from hachoir_metadata import extractMetadata
from hachoir_core.i18n import getTerminalCharset
from sys import argv, stderr, exit

if len(argv) != 2:
    print >>stderr, "usage: %s filename" % argv[0]
    exit(1)
filename = argv[1]
filename, realname = unicodeFilename(filename), filename
parser = createParser(filename, realname)
if not parser:
    print >>stderr, "Unable to parse file"
    exit(1)
try:
    metadata = extractMetadata(parser)
except HachoirError, err:
    print "Metadata extraction error: %s" % unicode(err)
    metadata = None
if not metadata:
    print "Unable to extract metadata"
    exit(1)

text = metadata.exportPlaintext()
charset = getTerminalCharset()
for line in text:
    print makePrintable(line, charset)


Result:


Sunday, November 30, 2014

Installing Mutagen

As you have seen in previous post that it has used mutagen library for parsing mp3 and reading ID3 tags. Another powerful library for same purpose is eyed3 but relatively difficult to use in a Windows environment therefore mutagen was obvious choice.

I performed following steps to use mutagen in my python codes:

1. Downloaded latest tarball from lazka
2. Unzipped it and went inside to the folder ..\mutagen-1.27\dist\mutagen-1.27\mutagen-1.27 where I found setup.py
3. Made sure that python is available in system path env variable in windows
4. Build it with the command = python setup.py build
5. After build it created a build folder under ..\mutagen-1.27\dist\mutagen-1.27\mutagen-1.27 directory, inside which there was a lib folder and inside which I found the compiled mutagen folder structure.
6. Copied this mutagen folder structure inside ../build/libs directly into c:\python27 directory
7. Tried to execute the following code that went successful after the steps above:

from mutagen.id3 import ID3

audio_file_location = "audioFiles/Sleep Away.mp3"
audio_handler = ID3(audio_file_location)
print (audio_handler['TIT2'][0] )


Resources: