0

I want to get duration of .mp3 song in seconds using mp3info.

When I execute

mp3info -p "%S" file.mp3

output is

file.mp3 is corrupt or is not a standard MP3 file.

The file is correct 100%. When I execute the command, on same file, on another computer I get the correct information. The rpm version of mp3info is same on both computers.

Does anyone know what could be the problem?

3
  • Hm, without having the file I assume no one can answer this. Have you checked the file's checksum?
    – Manuel
    Jun 6, 2013 at 12:02
  • rpm? That would be redhat, not Ubuntu. You shuold install it through the Ubuntu package manager, not download a package meant for another OS.
    – psusi
    Jun 6, 2013 at 13:40
  • @Manuel yes I checked, and it is the same.
    – tasmaniski
    Jun 6, 2013 at 14:01

1 Answer 1

0

You could use something like avconv/ffmpeg which you should be able to then grep down. I recommend it because it's fairly robust and should look beyond broken headers:

$ avconv -i ~/Music/Aqua/Aquarium/*03*
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
  built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mp3 @ 0x733ce0] Header missing
[mp3 @ 0x732960] max_analyze_duration reached
[mp3 @ 0x732960] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/home/oli/Music/Aqua/Aquarium/Aqua - 03 - Barbie Girl.mp3':
  Metadata:
    title           : Barbie Girl
    track           : 03/11
    artist          : Aqua
    album           : Aquarium
    genre           : European Pop
    TLEN            : 198008
    album_artist    : Aqua
    TBPM            : 130
    date            : 1999
  Duration: 00:03:50.32, start: 0.000000, bitrate: 128 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
At least one output file must be specified

Then just apply awk liberally:

$ avconv -i ~/Music/Aqua/Aquarium/*03* 2>&1 | awk '/Duration/ {print $2}' | tr -d ,
00:03:50.32
1
  • I started using ffmpeg, it did the job.
    – tasmaniski
    Jun 6, 2013 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .