views:

22

answers:

2

I need to serve MP3 content that is generated dynamically during the request. My clients (podcatchers I can't configure) are timing out before I'm able to generate the first byte of the response data.

Is there a way to send fodder/throwAway data while I'm generating the real data, to prevent/avoid the timeout, but in a way that allows me to instruct the client to ignore/discard the fodder data once I'm ready to start sending the "real" data?

+2  A: 

If the first few bytes of the encoded content are always the same then you could very slowly send back those bytes. I'm not familiar with the MP3 file format, but if the first few bytes are always some magic (and constant) header, this technique could work.

Once the file encoding gets started you could then skip the first few bytes (since you already sent them) and continue from there.

Eilon
This is a good idea. My encoded contents starts differently each time. I considered John Feminella's idea below, and I'll comment there on the results of that effort.
lance
+1  A: 

You could have a default, static "hi, welcome to Lance's stream!" stream go out while you're generating the real deal.

John Feminella
I did this, and it worked, but only for some media players. Turns out that making it work in all media players would require an expertise in MP3 files that just isn't in my schedule now. Related: http://stackoverflow.com/questions/2099301/mp3-created-from-two-others-wont-play-in-wmp11
lance
That's true; you'd have to modify your MP3 headers so that the length was incremented by the amount of time your "welcome" stream plays.
John Feminella