Consider using Squash
Feel free to close this if you're not interested.
It seems like this would be a really good fit for using Squash. You would get support for a lot of codecs.
Another option would be to add a preprocessor layer to Squash, and making a Squash plugin for XWRT. This would obviously require some work on my end, but it is something I'm interested in doing. I've just created quixdb/squash#165 for the idea; it's probably more of a long-term goal, so it may still make sense to add a Squash backend in the shorter term.
I like the idea of making a Squash plugin for XWRT. The problem with XWRT is that it was not designed as a separate filter/preprocessor. Now I would write it differently, but I do not have time and motivation to rewrite it.