I'm working on concatenating videos again, this time with different playback speeds. The video stream part is easy enough, but the audio part is what's stumping me at the moment.
Currently, I've managed to do it by just multiplying the timestamp by a factor inversely derived from the desired playback speed, so that if the playback is to be half speed, the timestamps are multiplied by two.
Not only that, I've also altered the audio samples (in the form of a byte array) so that when the playback is half speed, every sample (of four bytes) is repeated, and when the playback is double speed, every second sample is discarded.
My problem is that this method also alters the pitch of the resulting audio track - the half-speed playback lowers the pitch, the double-speed playback raises it.
How can I resample these samples without altering their pitch?