In article ,
David Nebenzahl wrote:
If you could, it would be trivially easy to write a program which would
read an MP3, change some bits in the header and rewrite it. (The hardest
part would be if you had to recalculate a checksum because of the
changed data, but even this is a piece of cake.)
Based on what I know/read of MPEG audio encoding, I think that the
problem you're trying to solve *is* solvable, but is rather more
complex than you would wish.
In order to swap channels in an MP3 stream, you'd need to do something
along the following lines:
- Separate the stream into frames, by detecting the frame syncs and
parsing the headers.
- Un-do the Huffman coding (a lossless operation) to recover the
frame full of perceptually-coded data (this is a lossless operation)
- Based on the information in the mode and mode extension fields,
"tear apart" the encoded (quantized) data for the left and right
channels, and then "put it back together" in the opposite
orientation. In the case of a joint-stereo encoding I imagine that
this might require swapping the sign of the inter-channel
difference value. I *think* that this swapping-around could be
done losslessly (without decoding and then re-encoding), at least
in most cases, but I can't swear to that.
- Do a new pass of Huffman encoding (which is lossless) and put the
frame headers onto each Huffman block (this might require changing
the padding bits).
- Stream out the frames.
--
Dave Platt AE6EO
Friends of Jade Warrior home page:
http://www.radagast.org/jade-warrior
I do _not_ wish to receive unsolicited commercial email, and I will
boycott any company which has the gall to send me such ads!