.......
.......
var mixer = new WaveMixerStream32();
mixer.AutoStop = true;
var messageOffset = background.TotalTime;
var messageOffsetted = new WaveOffsetStream(message,
TimeSpan.FromSeconds(10),
TimeSpan.Zero,message.TotalTime.Subtract(TimeSpan.FromSeconds(10)));
var background32 = new WaveChannel32(background);
background32.PadWithZeroes = false;
background32.Volume = 0.6f;
mixer.AddInputStream(background32);
var message32 = new WaveChannel32(messageOffsetted);
message32.PadWithZeroes = false;
message32.Volume = 0.3f;
mixer.AddInputStream(message32);
var ws = new Wave32To16Stream(mixer);
We are trying to mix multiple mp3's and wave files to create a single MP3 finally.
Example: 5 sources files (3 mp3's, 2 wave files)
We are giving input of each stream to WaveMixerStream32 and finally converting it using Wave32To16Stream
We need this final stream to be converted to MP3. For this we are using LAME and passing the stream to EncodeMixedStreamAsMp3 which is returning an error "Invalid file format".
After researching, we found that RIFF header is missing in the mixed wave stream.
How to add a RIFF to a mixed wave stream which is generated based on multiple sources (MP3 and WAVE)?