How to display technical codec info for a FLAC file?

12,635

Solution 1

From the man page,

# -a, --analyze
# Analyze a FLAC encoded file (same as -d except an analysis file is written) 
flac -a myfile.flac

EDIT

It might be easier to use soxi from the Sound eXchange project. On most Linux systems you need to install the sox package. On Debian derived distributions (including Ubuntu), you would use

sudo apt-get install sox

Solution 2

metaflac --list will display that information (and more) for all blocks in a FLAC file. You can additionally use --block-number=X, where X is the block you want to have information about, to only get information about that particular block.

Solution 3

Easiest is to use the Unix command line utility file. For example:

file "example.flac" 
example.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 2474304 samples

Solution 4

You can use the ffprobe CLI tool that's included with ffmpeg:

$ ffprobe -hide_banner 10\ Ivory\ Tower.flac
Input #0, flac, from '10 Ivory Tower.flac':
  Metadata:
    ARTIST          : Van Morrison
    TITLE           : Ivory Tower
    ALBUM           : No Guru, No Method, No Teacher
    DATE            : 1986
    track           : 10
    GENRE           : Rock
    disc            : 1
    TOTALDISCS      : 1
    TOTALTRACKS     : 10
  Duration: 00:03:36.71, start: 0.000000, bitrate: 946 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16

Shows the duration, bitrate, and particulars about the FLAC encoding. ffmpeg/ffprobe use the term streams, so the file we gave it is considered Stream#0:0.

You can get just those details:

$ ffprobe -hide_banner 10\ Ivory\ Tower.flac |& grep Stream
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16

Or if you really want to get at all the data from the stream use the -show_stream:

$ ffprobe -hide_banner  -show_streams 10\ Ivory\ Tower.flac
Input #0, flac, from '10 Ivory Tower.flac':
  Metadata:
    ARTIST          : Van Morrison
    TITLE           : Ivory Tower
    ALBUM           : No Guru, No Method, No Teacher
    DATE            : 1986
    track           : 10
    GENRE           : Rock
    disc            : 1
    TOTALDISCS      : 1
    TOTALTRACKS     : 10
  Duration: 00:03:36.71, start: 0.000000, bitrate: 946 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
[STREAM]
index=0
codec_name=flac
codec_long_name=FLAC (Free Lossless Audio Codec)
profile=unknown
codec_type=audio
codec_time_base=1/44100
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=s16
sample_rate=44100
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
duration_ts=9556764
duration=216.706667
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=16
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]

See references below for more examples etc.

References

Share:
12,635

Related videos on Youtube

landroni
Author by

landroni

Updated on September 18, 2022

Comments

  • landroni
    landroni almost 2 years

    Given a .flac file, how is it possible to query and display the technical info relating to the codec? I looked into man flac with no luck (the --analyze output is not humanly parseable). I'm specifically interested in the bit rate (say, 16 bits per sample), the sample rate (say, 44.1 KHz) and the number of channels.

    Either GUI or CLI utilities are acceptable.

    • Andrei Istratov
      Andrei Istratov almost 6 years
      VLC player can show you all this information
  • landroni
    landroni over 10 years
    Yes, I tried that. But the output is completely bonkers to me.
  • Elliott Frisch
    Elliott Frisch over 10 years
    @landroni Okay. Edited to add soxi.
  • landroni
    landroni over 10 years
    Perfect. soxi does what I wanted.
  • Stilez
    Stilez over 10 years
    Try flac -ac file.flac | grep -E '(sample|channels)' for a quick 2 out of 3 answers. All those gui tools do is read from that sort of output... Also -a will create an .ana file with the output... -c allows output to stdout.
  • landroni
    landroni over 10 years
    metaflac is also very useful.
  • Ákos
    Ákos almost 10 years
    The commands: metaflac --show-bps, metaflac --show-channels, metaflac --show-sample-rate, will do exactly what the OP poster wanted. Thanks for suggesting metaflac in the first place!