Willem de Jong wrote:
Hello List,
This may be somewhat off topic - my apologies. I am writing to this list because I hope to find someone here who can help me with a problem concerning ADPCM encoded sound in SWF (flash) files.
I have sent a similar request to Adobe, and they referred me to ffMpeg. To the sourcecode, not to the mailing list, but unfortunately I haven't managed to find the answer in the sourcecode - I am not a C programmer.
I am trying to create an ADPCM encoder in Erlang, a functional programming language.
The encoded sound will be part of a Flash file, so it has to be in blocks of 4095 samples, with an uncomressed sample and a step-index preceding each
Hi, look at the adpcm_swf implementation in libavcodecs/adpcm.c. There you will see how you need to frame the packets.
block, as described in version 10 of the SWF and FLV Flash File Format specification.
Unfortunately I do not succeed in getting the values for these uncompressed samples and the step-index right. Whatever I try, I keep hearing a small noise in between the blocks. I am actually beginning to wonder whether it is perhaps a problem of the flash player.
The Flash File spec refers to a C program by Jack Jansen, but that doesn't help me, because that program is not doing the framing that Flash requires.
My assumtion is that it should work as follows:
- for the very first block, I can simply take 0 for both the InitialSample and the InitialIndex. This causes a slight distortion of the first wave, but that doesn't matter.
- when I have reached the last sample of a block, I calculate the "predicted value", using the current index-step value and the previous (predicted) value (just as I would do if this would not be the last sample). I put this predicted value and the new index-step into the appropriate fields of the new ADPCMMonoPacket, and I move on to the next sample.
Result: the noise a mentioned. As I said, I have tried various other approaches (even really weird ones), but nothing helps.
So, if there is anyone who understands the SWF ADPCM encoding: you help will be greatly appreciated!
Regards, Willem
MvH Benjamin Larsson