mp3plot

An mp3 bitrate plot tool

Projects index

  • Current version: 0.6.0, released on June 22nd 2009
  • Status: stable, work in progress
  • Released under the GNU GPL
  • Online man page: html, pdf
  • New releases announced on my site
  • Example, text mode, run:
    $ mp3plot "the file.mp3"
    mp3plot 0.6.0 (c) 2007, 2009 Toni Corvera <http://p.outlyer.net/mp3plot>
    
    Tag Identifier / File Magic: ID3
    Tag version: 0x0000
    ID3V2 Flags: 0x00
    Tag size: 559
    * Information gathered from the first frame:
    MPEG Version: MPEG v1
    MPEG Layer: Layer III
    Has CRC: No
    Nominal bitrate: 128 kbps
    Sampling rate: 44100 Hz
    Channel mode: Joint Stereo
    * VBR Information: 
    VBR file
    Number of frames included (15295)
    File size included (7522979)
    TOC included
    VBR scale included
    * Bitrate plot:
    [   free]: 0    
    [ 32kbps]: 41   
    [ 40kbps]: 7    
    [ 48kbps]: 8    
    [ 56kbps]: 8    
    [ 64kbps]: 7    
    [ 80kbps]: 32   
    [ 96kbps]: 358  ..
    [112kbps]: 1228 ........
    [128kbps]: 3186 .......................
    [160kbps]: 8720 ...............................................................
    [192kbps]: 1700 ............
    [224kbps]: 0    
    [256kbps]: 0    
    [320kbps]: 0    
    [invalid]: 0
    Average bitrate is 150.81 kbps
    with a total of 15295 frames
    which yields a theoretical (raw audio data) size of 7496918 bytes
    and a length of 399s

This tool prints out a plot of the bitrate distribution of a VBR MP3 file (it will also do it for CBR files although it isn't very meaningful).

There's a much more mature tool that does the same and more: mp3stat at signal-lost.homeip.net/projects (dead link, archived version, page at BSDforge).
mp3stat refuses to work on my system(s) and having an interest in mp3's internal structure I gave a shot at it with mp3plot.

Graphical plots can also be generated by adding the -g option (note this is an optional feature and might not be included in your copy).
This feature was added in version 0.4.0a but is only really usable from 0.5.0 onwards.

Example: (plot for the same file as in the textual example above)

GD output
GD

Magick output
Magick++
GD output using the older colourscheme
GD, old colours
Magick output using the older colourscheme
Magick++, old colours

The graphics output support can be provided by two different libraries (gd and ImageMagick —or GraphicsMagick—).
All binaries in this page use GD since it produces sharper output.

OS/Platform Package Dependencies
Debian Sid i386 Sid @ 2009-06-22
mp3plot_0.6.0-upstream.1_i386.deb
libboost-program-options1.35.0 (>= 1.35.0-1), libboost-thread1.35.0 (>= 1.35.0-1), libc6 (>= 2.3.6-6~), libgcc1 (>= 1:4.1.1), libgd2-noxpm (>= 2.0.36~rc1~dfsg) | libgd2-xpm (>= 2.0.36~rc1~dfsg), libstdc++6 (>= 4.2.1)
Sid @ 2010-02-21
mp3plot_0.6.0-upstream.1-SID20100221_i386.deb
libboost-program-options1.40.0 (&gt;= 1.40.0-1), libboost-thread1.40.0 (&gt;= 1.40.0-1), libc6 (&gt;= 2.3.6-6~), libgcc1 (&gt;= 1:4.1.1), libgd2-noxpm (&gt;= 2.0.36~rc1~dfsg) | libgd2-xpm (&gt;= 2.0.36~rc1~dfsg), libstdc++6 (&gt;= 4.4.0)
Debian Sid amd64 Sid @ 2009-06-22
mp3plot_0.6.0-upstream.1_amd64.deb
libboost-program-options1.35.0 (&gt;= 1.35.0-1), libboost-thread1.35.0 (&gt;= 1.35.0-1), libc6 (&gt;= 2.3.2), libgcc1 (&gt;= 1:4.1.1), libgd2-noxpm (&gt;= 2.0.36~rc1~dfsg) | libgd2-xpm (&gt;= 2.0.36~rc1~dfsg), libstdc++6 (&gt;= 4.2.1)
Sid @ 2010-02-21
mp3plot_0.6.0-upstream.1-SID20100221_amd64.deb
libboost-program-options1.40.0 (&gt;= 1.40.0-1), libboost-thread1.40.0 (&gt;= 1.40.0-1), libc6 (&gt;= 2.3.2), libgcc1 (&gt;= 1:4.1.1), libgd2-noxpm (&gt;= 2.0.36~rc1~dfsg) | libgd2-xpm (&gt;= 2.0.36~rc1~dfsg), libstdc++6 (&gt;= 4.4.0)
Fedora 10 i686 mp3plot-0.6.0-1.fc10~upstream.i386.rpm libboost_program_options-mt.so.3 libboost_thread-mt.so.3 libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1.3) libgcc_s.so.1 libgcc_s.so.1(GCC_3.0) libgd.so.2 libpthread.so.0 libpthread.so.0(GLIBC_2.0) libstdc++.so.6 libstdc++.so.6(CXXABI_1.3) libstdc++.so.6(GLIBCXX_3.4) libstdc++.so.6(GLIBCXX_3.4.9) rpmlib(CompressedFileNames) &gt;= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) &gt;= 4.0-1 rtld(GNU_HASH)
FreeBSD 7.1-RELEASE amd64 1) mp3plot-0.6.0_amd64.tbz png-1.2.32; gd-2.0.35,1; boost-1.34.1
Microsoft Windows (x86) mp3plot-0.6.0-win.zip (included)

Additionally the sources include means to produce easily deb, rpm and tbz (FreeBSD) packages for other OS/architecture combinations.

Generic build instructions

Mandatory requirements:

  • boost headers
  • boost program-options
  • boost thread (at least 1.34.1)
  • C++ compiler (preferably g++), libraries and tools

Optional requirements (for graphical plots):

  • gd library
  • ImageMagick or GraphicsMagick library (currently gd is preferable)

Compile in the standard GNU fashion:

$ tar zxvf mp3plot-0.6.0.tar.gz
$ cd mp3plot-0.6.0
$ ./configure
$ make
# make install

configure will link against the graphics libraries available (binaries can link to both GD and *Magick at once).
Use –disable-* arguments to avoid linking in undesired modules, e.g.:
Compile without gd support $ ./configure –disable-gd
Compile without *Magick support $ ./configure –disable-magick
Compile without graphics support $ ./configure –disable-gd –disable-magick

NOTE  If configure has problems finding the boost libraries, refer to the INSTALL file in the tarball.

Build DEB package

Packages required to build DEB in Debian Sid:

  • Libraries: libgd2-noxpm-dev, libboost-thread-dev OR libboost-thread1.35-dev, libboost-program-options-dev OR libboost-program-options1.35-dev.
  • C++ compiler: g++
  • Deb build stuff: dpkg-dev, debhelper and optionally devscripts
$ tar zxvf mp3plot-0.6.0.tar.gz
$ cd mp3plot-0.6.0
$ dpkg-buildpackage -rfakeroot -us -uc -b   # (or ''debuild -us -uc -b'')

Build RPM package

Packages required to build RPM in Fedora 10:

  • Libraries: gd-devel, boost
  • C++ compiler: gcc-c++
  • RPM build stuff: rpm-build
$ rpmbuild -tb mp3plot-0.6.0.tar.gz

Build FreeBSD port

Extract port-0.6.0.tar.gz to ${PORTSDIR}/audio/mp3plot and proceed normally from there, e.g:

$ cd /usr/ports/audio/mp3plot
$ tar -zxvf port-0.6.0.tar.gz
$ make
  • Expected for 0.7.0
    • Allow user-specified output image size
    • Optionally display generated image
  • Expected before 1.0
    • Handling of free-form bitrate

I got most of my initial reference information on the MP3 file structure from the MP3 File Structure Description document located at www.goat.cz/index.php?path=MP3_MP3ProfiInfo (older URL.)
More information filled through web searches leading to random sites.

List of sources of information used, in no particular order:

Portions of the source code to compile on Visual C++ come from the msinttypes project, which is © 2006-2008 Alexander Chemeris, published under the terms of a BSD 3-clause license.

The initial ports collection integration effort was by Andrew Pantyukhin.

wav2mp and UZURA1 were used to generate some MP1 samples.

Lots of fixed of sloppy code and support for Layer I (MP1), Layer II (MP2) and MPEG-2 (MP1, MP2 and MP3 at lower sampling rates).

  • Fixed detection of sampling rate (defaulted to 44.1kHz) and CRC flag (displayed its value reversed).
  • Fix of nasty bug with free-form bitrate and corrupted files that led to an infinite loop eventually exhausting memory.
  • More warnings where appropriate
  • Print the theoretical length in seconds

See the full changelog for the complete list of changes.

  • Graphics output alignment corrections.
  • Single-hue graphics output by default.
  • Other bugfixes and minor cosmetic changes, see the full ChangeLog for a complete list.
  • Image output is usable (not final though), both gd and/or ImageMagick++/GraphicsMagick++ can be used. If both are compiled in, one or the other can be chosen with “-n”.
  • Allow choosing the output file name with “-o
  • Display a list of available plotters with “-p list
  • Support Microsoft Windows
  • Documentation: Added manpage (converted to PDF for Windows distribution)
  • Bugfix: Print usage information when command-line is incorrect
  • Experimental image support
  • Cleanup of the build system and adoption of the standard <kbd>./configure &amp;&amp; make</kbd> cycle
  • Many internal changes, cleanups and redesigns.

© 2007-2010 Toni Corvera < outlyer at gmail dot com >

<!–$Rev: 2280 $–>


1)
FreeBSD includes mp3plot in its ports/packages system (audio/mp3plot). As of this writing it is up-to-date. See External references.
All dates/times in this page are UTC.
  • mp3plot.txt
  • Last modified: 2024/04/02 18:05
  • by Toni Corvera