audioinfo
Information about audio file
Description
Examples
Get Information About Audio File
Create a WAVE file from the example file handel.mat
, and get information about the file.
Create a WAVE (.wav) file in the current folder.
load handel.mat filename = 'C:\Temp\handel.wav'; audiowrite(filename,y,Fs); clear y Fs
Use audioinfo
to return information about the WAVE file.
info = audioinfo(filename)
info = struct with fields: Filename: 'C:\Temp\handel.wav' CompressionMethod: 'Uncompressed' NumChannels: 1 SampleRate: 8192 TotalSamples: 73113 Duration: 8.9249 Title: [] Comment: [] Artist: [] BitsPerSample: 16
Input Arguments
filename
— Name of file
character vector | string scalar
Name of file, specified as a character vector or string scalar that includes the file extension.
Depending on the location of your file, filename
can
take on one of these forms.
Current folder | Specify the name of the file in
Example:
| ||||||||
Other folders | If the file is not in the current folder or in
a folder on the MATLAB® path, then specify the full or
relative path name in
Example:
Example:
| ||||||||
Internet URL | If the file is specified as an internet uniform
resource locator (URL), then
Example:
| ||||||||
Remote Location | If the file is stored at a remote location,
then
Based on the remote
location,
For more information, see Work with Remote Data. Example:
|
Example: 'myFile.mp3'
Example: '../myFile.mp3'
Example: 'C:\temp\myFile.mp3'
audioinfo
supports the following file formats.
Platform Support | File Format |
---|---|
All platforms | AIFC (.aifc ) |
AIFF (.aiff , .aif ) | |
AU (.au ) | |
FLAC (.flac ) | |
OGG (.ogg ) | |
OPUS (.opus ) | |
WAVE (.wav ) | |
Windows® 7 (or later), Macintosh, and Linux® | MP3 (.mp3 ) |
MPEG-4 AAC (.m4a , .mp4 ) |
On Windows 7 platforms (or later), audioinfo
might
also return information about the contents of any files supported by
Windows Media® Foundation.
On Linux platforms, audioinfo
might also return
information about the contents of any files supported by GStreamer.
audioinfo
can extract audio metadata from MPEG-4
(.mp4
, .m4v
) video files on
Windows 7 or later, macOS 10.7 Lion or higher, and Linux, and from Windows Media Video (.wmv
) and AVI
(.avi
) files on Windows 7 (or later) and Linux platforms.
Data Types: char
| string
Output Arguments
info
— Information about audio file
structure
Information about audio file, returned as a structure. info
can
contain the following fields.
Field Name | Description | Data Type |
---|---|---|
Filename | Filename including the absolute path to the file and the file extension. | character vector |
CompressionMethod | Compression method used. | character vector |
NumChannels | Number of audio channels encoded in the audio file. | double |
SampleRate | Sample rate of the audio data in the file, in hertz. | double |
TotalSamples | Total number of audio samples in the file. | double |
Duration | Duration of the file, in seconds. | double |
BitsPerSample | Number of bits per sample encoded in the audio file. Only
valid for WAVE ( | double |
BitRate | Number of kilobits per second (kbit/s) used for compressed audio files. Only valid for MP3 ( | double |
Title | Value of 'Title' , if any. | character vector |
Artist | Value of 'Artist' , if any. | character vector |
Comment | Value of 'Comment' , if any. | character vector |
Note
The BitRate
property returns the actual bit
rate on Mac platforms, and not the encoded bit rate. This means
that bit rate values might be lower than specified at the time of
the encoding, depending on the source data.
Note
On Mac platforms, audioinfo
returns metadata
from .m4a
and .mp4
files only on
macOS 10.7 Lion or higher. Previous versions of macOS will not read the 'Title'
,
'Author'
, or 'Comment'
fields.
Limitations
For MP3 and MPEG-4 AAC audio files on Windows 7 or later and Linux platforms,
audioinfo
might report fewer samples than expected. On Linux platforms, this is caused by a limitation in the underlying GStreamer framework.On Linux platforms,
audioinfo
interprets single channel data in MPEG-4 AAC files as stereo data.For MP3 files on Windows platforms,
audioinfo
might not report values in theArtist
,Title
, orComment
fields of the output structure. This omission is caused by a limitation in the underlying Windows Media Foundation library.
Version History
Introduced in R2012bR2022a: Analyze Opus (.opus
) audio files
You can analyze Ogg Opus audio files.
R2021a: Analyze audio files from an HTTP or HTTPS URL
You can analyze audio files from an internet URL by specifying
filename
as a string or character vector that contains the
protocol type 'http://'
or 'https://'
.
R2020b: Analyze audio files from a remote location
You can analyze audio files stored in remote locations, such as Amazon S3, Windows Azure Blob Storage, and HDFS.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)