Basically you need to decode the stream from the original format and encode it again in the format, but is far from trivial. Not sure if
Java performance will be adequate, a C/C++ application probably will run faster (although the JVM is pretty fast).
I'll try to stay away and find an utility to do that. (also some formats have protected content, and that's another whole can of worms
)