views:

69

answers:

2

I'm trying to create a FUSE fs which transcodes all sound files to mp3. My first idea is to use gstreamer as the backend for transcoding. I thought about using this pipeline:

gst-launch -v filesrc location=01\ New\ Born.flac ! decodebin ! audioconvert ! lame vbr=4 vbr-quality=9 ! id3v2mux ! appsink

The python bindings of fuse expect calls this function when a file is being read:

def read(self, length, offset):

How would I transfer the buffer from gstreamer to the fuse fs? I don't how to handle this. I've never used appsink before.

I hope it's clear what I mean.

A: 

I don't think you need to bother with appsink. My gut feeling is that the further you can separate the transcoding part from the filesystem part the better. Transcode in a separate thread or process into a filesink and pass messages to tell the FUSE daemon how far transcoding has progressed.

Instead of appsink, I'd use filesink, transcode in a number of worker threads/processes that write .mp3s to a size-controlled cache directory, and have read() block until the transcoded file in progress is long enough to fulfill the request.

Here's the source for filesink. In the absence of seeks, it appears to just append the contents of each buffer to the file. http://mediatools.cs.ucl.ac.uk/nets/newvideo/browser/gst-cvs/gstreamer/plugins/elements/gstfilesink.c#L436

You could also save yourself a lot of time and trouble by just downloading mp3fs or gstfs which already accomplish pretty much exactly what you mention.

joeforker
A: 

Have you tried: giosink Write to any GIO-supported location giosrc Read from any GIO-supported location

With Gio you should be able to treat FUSE as any file system.

Andreas Tunek