Store multiple channels with different encoding / sampling in a single WAV file


I have two RTP streams (one for each call direction) that I want to mix in a single WAV file.

The problem is that the two streams may use different codecs (and therefore different sampling frequency, encoding, etc).

Is it possible to store the two RTP streams in a WAV file using two channels (i.e. stereo)? Asked differently, is there a way to store multiple channels with different encoding, sampling frequency, etc?

Structure of the WAV file assumes that sampling rate and channel bitness is the same for all channels of the feed. Encoding applies the entire feed (with many encodings/formats/codecs you cannot separate a channel without decoding the feed).

You will need to store feeds in separate files, or you need a file format which supports multiple audio tracks (MP4, MKV for example) though they all have their own restrictions.