Audio Type Conversion

trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-04-04 04:27

Is there a way on how can I develop a module that will auto-convesrt its type to *.mp3?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-04-04 17:47

yes, you could write a toolkit module that registers an operation called convert-to-audio/mp3
you'd need some underlying php function or external binary to do the actual conversion..

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Wed, 2006-04-05 20:45

thanks. is there an existing module that i can use as guide? does the "audio/mp3" in
"convert-to-audio/mp3" have to be a valid mimetype? i've just checked now, the correct mimetype
for mp3 is audio/mpeg.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-04-05 21:38

well, the operation name is just a name, but of course you should put the right mime type there.. oops.
try looking at dcraw module

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Thu, 2006-04-06 17:59

It seems that I an upload of an audio file don't trigger my Toolkit Class. What may be the problem here?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2006-04-06 22:12

You registered the convert-to-audio/mpeg operation?
When uploading a file G2 tries to make a thumbnail for it, so it will look for "thumbnail" or "convert-to-image/jpeg" operations for the uploaded mime type.. there isn't any code to look for the operation you added.

Now that you have a toolkit you need to figure out how to integrate use of that toolkit into the application. Maybe register an ItemAddOption that automatically creates a derivative using your toolkit operation when audio/* items are added.