添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I would like to extract meta data from a MP3 file. This is going into a script, and I therefore want to do it from the command line. Since I have already installed ffmpeg, I thought I could use it for this purpose. I found here the following description:

Extracting an ffmetadata file with ffmpeg goes as follows:

ffmpeg -i INPUT -f ffmetadata FFMETADATAFILE

I tried it like this:

ffmpeg -i InSpace.mp3 -f ffmetadata meta.txt

and found that it indeed created meta.txt with the required data, but also dumped the meta data in a different format to stderr, together with the error message Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used). In addition, it prints this pagination prompt to stderr:

Stream mapping:
Press [q] to stop, [?] for help

and then waiting for me to input something.

Of course I can get around this by writing the command as

ffmpeg -i InSpace.mp3 -f ffmetadata meta.txt </dev/null 2>/dev/null

but this looks pretty inelegant, and it also means that real error messages are also thrown away.

What did I do wrong? Or, is there a better way to extract the meta-data from the command line?

UPDATE:

Following the suggestion in the comment by gregg, I tried:

ffprobe -show_entries 'stream_tags : format_tags' InSpace.mp3 

This also produced a lot of text on stderr (including such information like which gcc version was used to create the program), but also dumped the tags to stdout. Of course I can redirect the stderr to /dev/null again, and while the output format is slightly less convenient than the one produced by ffmpeg, getting the information on stdout is more flexible than the ffmpeg approach, which forces me to name a file for the tags. In this respect, I see ffprobe as an improvement over my approach to ffmpeg.

Nevertheless, I would like to understand why my ffmpeg command behaves in this way.

Instead ffprobe (think it's called) the tool designed for analyzing media files which I'm assuming includes metadata, but could totally be wrong ffmpeg.org/ffprobe.html – gregg Jan 13, 2022 at 13:18

FFmpeg command behavior is correct.
By default, FFmpeg is verbose.

You may select loglevel for getting only errors.
Use -y flag if you don't want FFmpeg to ask you if you want to overwrite an existing file.

ffmpeg -y -loglevel error -i InSpace.mp3 -f ffmetadata meta.txt

"Output file is empty, nothing was encoded" is just a warning - the text file is not considered to be an output file, because it's not an audio (or video) file.

You may select the output format of FFprobe using -of argument.
Selecting JSON format for example:

ffprobe -loglevel error -show_entries stream_tags:format_tags -of json InSpace.mp3
                I also found that by specifying a -  for the output file, the tags are written to stdout. It's convenient, that ffmpeg adheres to this convention!
– user1934428
                Jan 14, 2022 at 13:29

ffprobe I believe is the tool you want as it analyzes files vs. trying to convert/make files like ffmpeg. I am not terribly familiar with it, but its documentation is VERY large. I believe ffprobe -hide_banner (-hide_banner function detailed below) will hide that version info:

Suppress printing banner. All FFmpeg tools will normally show a copyright notice, build options and library versions. This option can be used to suppress printing this information.

Your command seemed needlessly complex & added more info (which you don't want?) to the output with Windows on my end:

The 'Writers' section of ffprobe documentation seems to deal with output to CSV or other files which appears to be what you are trying to do? If I am honest I skimmed your question because you seemed to be good in shells so maybe just needed help finding right tool & section of tools (man)ual/documentation.

This is also a -report switch that has TONS of info that has a TON of info that seems to be geared towards submitting bugs; its debug/log-level can be reduced from verbose (so less info).

The -hide_banner indeed produces less information, but still prints on stderr variosu information, such as encoder : LAME3.99r, so I must still redirect stderr if I don't want to see it. Moreover, it does not display the tags. To get the tags printed, I have to use -show_entries 'stream_tags : format_tags'. I'm using ffprobe 9.1.1 on Windows (via a Cygwin zsh). – user1934428 Jan 14, 2022 at 9:04