PCMU Audio in H264 stream to Wowza

Topics: Question
Aug 23 at 7:37 AM
I have a problem with creating one stream which contains audio and video from audio and video separately. I'm using net7mma library for rtsp server. I'm streaming video to wowza. I got H264/AVC video raw stream and PCMU 44,1k samplerate audio stream.
This is how I do this:
Firstly I create media:
RFC6184Media newMedia = new RFC6184Media(704, 480, camName);
Then when video frame comes I do:
var newFrame = new RFC6184Media.RFC6184Frame(96);
newFrame.Packetize(buff);
media.AddFrame(newFrame);
For this steps everything works fine, video looks good. The problem is when I want to add audio. From my device I receive raw PCMU 8k sample rate so I need to resample it to 44100 using NAudio library:
var provider = new RawSourceWaveStream(new MemoryStream(buff), new WaveFormat(8000, 1));
provider.ToSampleProvider();

var outFormat = new WaveFormat(44100, provider.WaveFormat.Channels);
var resampler = new WaveFormatConversionStream(outFormat, provider);

MemoryStream memStr = new MemoryStream();

WaveFileWriter.CreateWaveFile("pcm", resampler);
var audioBytes = File.ReadAllBytes("pcm");

var newFrame = PacketizeBufer(audioBytes);
media.AddFrame(newFrame);
My method for packetization looks like this:
 private RtpFrame PacketizeBufer(byte[] messageBuffer)
    {
        var newFrame = new RtpFrame(0);
        int countOfArray = messageBuffer.Length / 1500;
        if (messageBuffer.Length % 1500 > 0)
            countOfArray++;
        RtpPacket packet;
        for (int i = 0; i < countOfArray; i++)
        {
            byte[] tempToSend = messageBuffer.Skip(i * 1500).Take(1500).ToArray();
            if (i == countOfArray - 1)
            {
                packet = new RtpPacket(2, false, false, true, 0, 0, 0, i, 0, tempToSend);
                newFrame.Add(packet);
                break;
            }
            packet = new RtpPacket(2, false, false, false, 0, 0, 0, i, 0, tempToSend);
            newFrame.Add(packet);
        }
        return newFrame;
    }
SDP looks like this:
v=0
o=ASTI-Media-Server 15943110217466738919 -2503633856242812693 IN IP4 [ip_addr]
s=ASTI-Streaming-Session-stream-name
a=sendonly
a=type:broadcast
a=rtpmap:0 PCMU/44100
a=fmtp:0 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z0LAHtkDxWhAAAADAEAAAAwDxYuS,aMuMsg==
a=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z0LAHtkDxWhAAAADAEAAAAwDxYuS,aMuMsg==
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=control:/live/b8f38900-b1ba-4dda-b00c-2ccd6f847c61/video
m=audio 0 RTP/AVP 0
a=control:/live/b8f38900-b1ba-4dda-b00c-2ccd6f847c61/audio
Session=> 2359fd8e-f449-4db7-a19e-48ca78cc3422
The strange thing about this is when I save video and audio to one file it won't work. When I save video and audio separately (video as h264, audio as wav) video gest audio somehow.