SYNOPSIS
map = audio.mediainfo(filename)
DESCRIPTION
Gathers information about the media file in filename. Returns a table with key/value pairs.
Supported file mime-types are ogg/vorbis (*.ogg) and audio/wave (*.wav).
Mime type is detected by looking into the file, the file extension is ignored.
The following fields are common for all mime types:
mimetype | MIME data type of the file. |
playtime | Playback length of the file in milliseconds. This field does not exist if this value can not be determined! |
Specific fields for ogg/vorbis mime type:
rate | Samples per second of the uncompressed data stream. |
channels | Number of channels (e.g. 1=mono, 2=stereo). |
version | Number value taken verbatim from the vorbis container. |
bitrate | A table containing the number values named lower, upper, nominal and window. Taken verbatim from the vorbis container. |
comments | A table containing key/value string pairs from comment section of the vorbis container. The file format supports any key/value combination. Some key names have been agreed upon, see example below. |
Specific fields for audio/wave mime type:
rate | Samples per second. |
bits | Bits per sample. |
channels | Number of channels (e.g. 1=mono, 2=stereo). |
RETURN VALUE
Returns a table with media file information.
ERRORS
On error, three values are returned: nil, a string describing the error (The result of the C
library call strerror() on the errno code) and the errno number from the standard C library.
EXAMPLE
The example file has been edited to put example text in all typical tag fields
that are offered by common tag editors.
>
print(table.tostring(audio.mediainfo("example.ogg"), 2))
{
mimetype = "ogg/vorbis",
playtime = 1062,
rate = 22050,
version = 0,
channels = 1,
bitrate = {
lower = 0,
upper = 0,
window = 0,
nominal = 40222
},
comments = {
CONTACT = "URL GOES HERE",
PERFORMER = "ORIG ARTIST GOES HERE",
TRACKTOTAL = "99",
GENRE = "GENRE GOES HERE",
ARTIST = "ARTIST GOES HERE",
COMPOSER = "COMPOSER GOES HERE",
["ENCODED-BY"] = "ENCODED-BY GOES HERE",
TRACKNUMBER = "01",
COPYRIGHT = "COPYRIGHT GOES HERE",
DATE = "1970",
TITLE = "TITLE GOES HERE",
ALBUM = "ALBUM GOES HERE",
DESCRIPTION = "COMMENT GOES HERE",
ALBUMARTIST = "ALBUM ARTIST GOES HERE"
}
}