FlacInfo
FlacInfo is a pure Ruby library for reading/writing low level information from Flac (Free Lossless Audio Codec) files.
flacinfo can extract the following information:
- Contents of the STREAMINFO block (bitrate, number of samples, md5 signature etc)
- Contents of the VORBIS_COMMENT block, ie: the tags...
- Contents of the SEEKTABLE block
- Size of PADDING block if present
- Size of CUESHEET block if present. The cuesheet itself is not parsed yet.
- Contents of the APPLICATION block if present.
- Contents of the PICTURE block if present, and write it to an external file (version 0.2).
flacinfo can write the following information back to the file:
- The Vorbis comments (version 0.3).
As an added bonus, if there is data present in a FlacFile APPLICATION block it can parse it, and dump the raw data to the console or a file.
FlacInfo has been tested on Linux and OS X. It should work on any Unix with Ruby, and on Windows as well. If you try the library on another OS/System please do let me know how it works for you. Please report all bugs and issues using FlacInfo's Rubyforge bug tracker.
documentation
Here is FlacInfo's Rdoc documentation.
Here is a brief example irb session:
$ irb --simple-prompt
>> require 'flacinfo'
=> true
>> s = FlacInfo.new("Nightmares On Wax - Smokers Delight - 12 - Mission Venice.flac")
=> #<FlacInfo:0x-4884f05c (STREAMINFO size=34 offset=8) (SEEKTABLE size=324 offset=46)
(VORBIS_COMMENT size=257 offset=374) (PICTURE size=26748 offset=635) (PADDING size=8104
offset=27387)>
>> s.comment
=> ["TITLE=Mission Venice", "ARTIST=Nightmares On Wax", "ALBUM=Smokers Delight",
"DATE=1995", "TRACKNUMBER=12", "TRACKTOTAL=16", "GENRE=Downtempo",
"DESCRIPTION=Ripped on January 8, 2008", "COMMENT=Ripped on January 8, 2008"]
>> s.comment_del("DESCRIPTION")
=> true
>> s.comment_add("HOW_MUCH_COFFEE_IVE_HAD=Too much")
=> true
>> s.comment
=> ["TITLE=Mission Venice", "ARTIST=Nightmares On Wax", "ALBUM=Smokers Delight",
"DATE=1995", "TRACKNUMBER=12", "TRACKTOTAL=16", "GENRE=Downtempo",
"COMMENT=Ripped on January 8, 2008", "HOW_MUCH_COFFEE_IVE_HAD=Too much"]
>> s.meta_flac
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
minumum blocksize: 4096 samples
maximum blocksize: 4096 samples
minimum framesize: 232 bytes
maximum framesize: 12897 bytes
sample rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 7504056
MD5 signature: 524546dcd49d11b1fa5732be3678cc3e
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 324
seek points: 18
point 0: sample number: 0, stream offset: 0, frame samples: 4096
point 1: sample number: 438272, stream offset: 1027419, frame samples: 4096
point 2: sample number: 880640, stream offset: 2079152, frame samples: 4096
point 3: sample number: 1318912, stream offset: 3158943, frame samples: 4096
point 4: sample number: 1761280, stream offset: 4260790, frame samples: 4096
point 5: sample number: 2203648, stream offset: 5359532, frame samples: 4096
point 6: sample number: 2641920, stream offset: 6442430, frame samples: 4096
point 7: sample number: 3084288, stream offset: 7532631, frame samples: 4096
point 8: sample number: 3526656, stream offset: 8502857, frame samples: 4096
point 9: sample number: 3964928, stream offset: 9397068, frame samples: 4096
point 10: sample number: 4407296, stream offset: 10321587, frame samples: 4096
point 11: sample number: 4849664, stream offset: 11274462, frame samples: 4096
point 12: sample number: 5287936, stream offset: 12177399, frame samples: 4096
point 13: sample number: 5730304, stream offset: 13221471, frame samples: 4096
point 14: sample number: 6172672, stream offset: 14317190, frame samples: 4096
point 15: sample number: 6610944, stream offset: 15399346, frame samples: 4096
point 16: sample number: 7053312, stream offset: 16475547, frame samples: 4096
point 17: sample number: 7495680, stream offset: 17332415, frame samples: 4096
METADATA block #2
type: 4 (VORBIS_COMMENT)
is last: false
length: 257
vendor string: reference libFLAC 1.2.1 20070917
comments: 9
comment[0]: TITLE=Mission Venice
comment[1]: ARTIST=Nightmares On Wax
comment[2]: ALBUM=Smokers Delight
comment[3]: DATE=1995
comment[4]: TRACKNUMBER=12
comment[5]: TRACKTOTAL=16
comment[6]: GENRE=Downtempo
comment[7]: COMMENT=Ripped on January 8, 2008
comment[8]: HOW_MUCH_COFFEE_IVE_HAD=Too much
METADATA block #3
type: 6 (PICTURE)
is last: false
length: 26748
type: 3 => Cover (front)
mimetype: image/jpeg
description: Front cover
image width: 240
image height: 240
colour depth: 24
number of colours: 0
image size: 26695 bytes
METADATA block #4
type: 1 (PADDING)
is last: true
length: 8104
=> nil
>> s.padding_resize!(1024)
=> true
>> s.padding
=> {"offset"=>27387, "block_size"=>1024}
>> s.write_picture()
=> nil
>> `ls *jpeg`
=> "Smokers Delight.jpeg\n"
>> quit
$
download
flacinfo-rb Ruby library
Download the Ruby library from the
flacinfo-rb rubyforge project page.
You can also install via remote gems:
# gem install -r flacinfo-rb
Or you can use this ebuild if you use Gentoo:
stats
It is
Sunday May 18, 2008 1:49 am
This page served 2459 times
This page last modified: April 14, 2008 11:28 am
Your IP address is: 38.103.63.17
You are browsing using: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
You are browsing from: United States.
badcomputer.org's uptime: 01:49:14 up 24 days, 02:31, 0 users, load average: 0.00, 0.00, 0.00
local
home | unix stuff | dir2ogg | sneetchalizer | wmainfo | q&d guide to permissions | q&d guide to tar and gzip | code | MS rant | browser shootout | linux & iAudio X5 | photos | music | programming poetry | sieve of Eratosthenes | plea | rain | suffer | archive | about | recipes | compaqr3000 | sitemap
search
credits
This page, and all pages on this site were created and are maintained by Darren Kirby using valid XHTML 1.0 and CSS, and are ©copyright 2002 - 2008. The Penguin image was created by Tukka, and is used by permission. Inspiration for the look of this site was provided by Eric A. Meyer's CSS gallery. This website runs on Gentoo Linux. It is served by Apache. PHP and MySQL hold together the backend.