Posted: . At: 10:32 AM. This was 4 years ago. Post ID: 14109
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to read ID3 data from an MP3 file on Linux with the command line.


Reading ID3 data from an MP3 file on Linux is very easy with the ffmpeg suite. The ffprobe command can do this very easily.

This example will return the title and artist of the MP3 file.

4.4 Mon Mar 02 jason@Yog-Sothoth 0: $ ffprobe -loglevel quiet -show_entries format_tags=artist,title 02\ Snake\ Hips.mp3 
[FORMAT]
TAG:title=Snake Hips
TAG:artist=The Future Sound Of London
[/FORMAT]

This example below is a version that removes all extraneous content around the text we wish to see.

4.4 Mon Mar 02 jason@Yog-Sothoth 0: $ ffprobe -loglevel quiet -show_entries format_tags=artist,title 02\ Snake\ Hips.mp3 | sed 's/\[[^]]*\]//g' | cut -d "=" -f 2
 
Snake Hips
The Future Sound Of London

Another example, using the -hide_banner parameter.

4.4 Mon Mar 02 jason@Yog-Sothoth 0: $ ffprobe -hide_banner -show_entries format_tags=artist,title 02\ Snake\ Hips.mp3 | sed 's/\[[^]]*\]//g' | cut -d "=" -f 2
[mp3 @ 0x5640e4f4e320] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '02 Snake Hips.mp3':
  Metadata:
    title           : Snake Hips
    album           : Far Out Son Of Lung And The Ra
    comment         : 
    publisher       : Astralwerks
    track           : 2
    compilation     : 1
    album_artist    : The Future Sound of London
    genre           : Electronica
    composer        : The Future Sound of London
    artist          : The Future Sound Of London
    date            : 1994
  Duration: 00:08:33.82, start: 0.000000, bitrate: 320 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
 
Snake Hips
The Future Sound Of London

This example shows all information whilst removing all unwanted square brackets and other unwanted data.

To extract the album art image from the MP3 if it has one, use ffmpeg.

4.4 Mon Mar 02 jason@Yog-Sothoth 0: $ ffmpeg -i 'This Is Darkness - Vol.1 Dark Ambient - 53 Creation VI - Mengir.mp3' art.jpg

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.