Steve's blog
   


Steve About
Steve's blog,
The Words of the Sledge
steve@einval.com

Subscribe
Subscribe to the RSS feed.

Links

  • Home
  • Debian
  • PlanetDebian
  • Search PlanetDebian
  • Friends

  • Matthew Garrett
  • Simon Huggins
  • Jonathan McDowell
  • Martin Michlmayr
  • Andrew Mobbs
  • David Pashley
  • Mike Pitt
  • Scott James Remnant
  • Daniel Silverstone

  •        
    Friday, 02 July 2010

    Fuse-music, a transcoding filesystem

    Now that disk space is cheap, it makes more and more sense to rip music and store it in FLAC format. I used to use abcde to encode directly to Ogg Vorbis, but a while back I decided to re-rip. The disks in the server at home now have lots of hours of music in a nice lossless format ready for easy playback on various machines on the network.

    However, that's not all I need. I also want to be able to create Ogg Vorbis files for my own music player with limited space. And Jo's Ipod won't play either .ogg or .flac (yay for closed devices!)... At least I now have readily-available original quality music already on hard disk, so I don't need to go and find CDs again. But I really don't want to have to work through my directories of music by hand, re-encoding individually.

    My solution: write a filesystem that will read in the .flac files and convert to .ogg or .mp3 on the fly. Now I can simply read the files I want off the server (via sftp/rsync/whatever) and it will create them for me!

    So, fuse-music is my first attempt to do this. It's a simple perl program that works using the perl FUSE bindings to generate a pseudo-filesystem where a tree of .flac files will appear as a tree of .ogg or .mp3 files instead. It's not wonderfully fast (as encoding takes time), but it works. The only major difficulty I have at this point is calculating the sizes of the output files: if I want rsync to work reliably then the reported sizes need to be static and correct. But it's not possible (AFAICS) to predict the size of an MP3 or Ogg Vorbis file without actually doing the encoding and measuring the output size. So (ick!) that's what the code currently does when necessary. It caches the output size in a perl hash DB so the work is only needed once per file; ideally I'd like to not to have to do this at all!

    If this sounds interesting at all, feel free to have a look at and play with the code: http://git.einval.com/cgi-bin/gitweb.cgi?p=fuse-music.git;a=summary and I'd love to hear your feedback.

    TODO:

    • Make it work with NFS?
    • Cache output for a while, rather than re-encode every time
    • Go multi-threaded, but may need to move to C for that, multi-threaded perl is nasty!
    • Add support for more output formats (wav/aac?)

    18:53 :: # :: /software/fuse-music :: 9 comments