如何从 mp3 文件中提取详细信息?

如何从 mp3 文件中提取详细信息?

如何使用 Linux 命令提取歌曲位置、艺术家、专辑、比特率、年份、流派等详细信息?我试过 mp3info,但它没有提供太多信息。请帮忙。谢谢!

答案1

你读过吗man mp3info?其中部分内容如下:

     -p "FORMAT_STRING"

          Print MP3 attributes according to FORMAT_STRING.  FORMAT_STRING is similar to a printf(3) format string in that it is printed verbatim except  for  the
          following conversions and escape sequences. Any conversion specifier may optionally include the various alignment, precision, and field width modifiers
          accepted by printf(3).  See the EXAMPLES section below for examples of how format strings are used in mp3info.

          Conversion Specifiers

             %f     Filename without the path [string]
             %F     Filename with the path [string]
             %k     File size in KB [integer]
             %a     Artist [string]
             %c     Comment [string]
             %g     Musical genre [string]
             %G     Musical genre number [integer]
             %l     Album name [string]
             %n     Track [integer]
             %t     Track Title [string]
             %y     Year [string]
             %C     Copyright flag [string]
             %e     Emphasis [string]
             %E     CRC Error protection [string]
             %L     MPEG Layer [string]
             %O     Original material flag [string]
             %o     Stereo/mono mode [string]
             %p     Padding [string]
             %v     MPEG Version [float]
             %u     Number of good audio frames [integer]
             %b     Number of corrupt audio frames [integer]
             %Q     Sampling frequency in Hz [integer]
             %q     Sampling frequency in kHz [integer]
             %r     Bit Rate in kbps (type and meaning affected by -r option)
             %m     Playing time: minutes only [integer]
             %s     Playing time: seconds only [integer] (usually used in conjunction with %m)
             %S     Total playing time in seconds [integer]
             %%     A single percent sign

答案2

更多来自man mp3info

显示当前目录中所有 MP3 文件的标题、艺术家、专辑和年份。我们包括标签File等,并插入换行符 ( \n),使内容更易于阅读:

mp3info -p "File: %f\nTitle: %t\nArtist: %a\nAlbum: %l\nYear: %y\n\n" *.mp3

更多的选择

-p "FORMAT_STRING"

    Print MP3 attributes according to FORMAT_STRING.  FORMAT_STRING
    is similar to a printf(3) format string in that it is printed
    verbatim except for  the following conversions and escape sequences.
    Any conversion specifier may optionally include the various
    alignment, precision, and field width modifiers accepted by
    printf(3). 
    See the EXAMPLES section below for examples of how format 
    strings are used in mp3info.

转换说明符

     %f     Filename without the path [string]
     %F     Filename with the path [string]
     %k     File size in KB [integer]
     %a     Artist [string]
     %c     Comment [string]
     %g     Musical genre [string]
     %G     Musical genre number [integer]
     %l     Album name [string]
     %n     Track [integer]
     %t     Track Title [string]
     %y     Year [string]
     %C     Copyright flag [string]
     %e     Emphasis [string]
     %E     CRC Error protection [string]
     %L     MPEG Layer [string]
     %O     Original material flag [string]
     %o     Stereo/mono mode [string]
     %p     Padding [string]
     %v     MPEG Version [float]
     %u     Number of good audio frames [integer]
     %b     Number of corrupt audio frames [integer]
     %Q     Sampling frequency in Hz [integer]
     %q     Sampling frequency in kHz [integer]
     %r     Bit Rate in kbps (type and meaning affected by -r option)
     %m     Playing time: minutes only [integer]
     %s     Playing time: seconds only [integer] (usually used in conjunction with %m)
     %S     Total playing time in seconds [integer]
     %%     A single percent sign

转义序列

     \n Newline 
     \t Horizontal tab 
     \v Vertical tab 
     \b Backspace 
     \r Carriage Return 
     \f Form Feed 
     \a Audible Alert (terminal bell) 
     \xhh Any arbitrary character specified by the hexidecimal number hh 
     \ooo Any arbitrary character specified by the octal number ooo 
     \\ A single backslash character

答案3

您可以使用mediainfo

sudo apt-get update && sudo apt-get install mediainfo

您可以使用选项提取各种信息--inform='<category>;%<parameter1>%[%<parameter2>%, ...]'<category>是表示一类参数的字符串,<parameterN>是表示该类别中参数的字符串;可以通过运行列出可用的类别和参数mediainfo --Info-Parameters;例如,以以下格式提取专辑和曲目的标题Album - Title

mediainfo --Inform='General;%Album% - %Title%' track01.mp3

答案4

ffprobe <themp3file.mp3>

相关内容