Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Converting RTP Packets into wav format and writing to a wav file dynamically

$
0
0
Hello Mark,

I am trying to use naudio for a specific requirement in my current project. I am streaming RTP packets containing audio payloads over network via UDP. I want to convert these packets into wav format and write them into a wav file dynamically. I saw your code sample on Stack Overflow demonstrating how to convert RTP into wav. In my case if I store the entire RTP stream received over the network into a file and then use this file to generate a wav file using naudio APIs it works fine and creates a wav file that I can play. Here is the code that I am using:

WaveFormat waveformat = WaveFormat.CreateMuLawFormat(8000, 1);
        Stream tmpMemStream = new FileStream(@"C:\test11.txt", FileMode.Open, FileAccess.Read);
        var reader = new RawSourceWaveStream(tmpMemStream, waveformat);
        using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader))
        {
            WaveFileWriter.CreateWaveFile(@"C:\output.wav", convertedStream);
        }
        tmpMemStream.Close();
However I want to convert the RTP packets into PCM stream dynamically that is as soon as I receive each set of RTP packets and write them immediately to a wav file. I want to initially create the wav file and then keep appending data to it as I receive the new RTP packets. Can you please suggest any APIs in naudio that I can use to achieve this functionality.

Thank you for your time.

Regards
Saleh

Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>