简体   繁体   中英

How to Transcode Opus codec to G.711 codec in C#

I am currently working with Mumble VoIP 1.2.X server-client communication protocol. My job is to create a desktop client where the client is connected with the server and receive other client's audio streams. I am receiving the stream in opus codec. I can decode it and also can play using NAudio library. Now I need to transcode the opus codec stream into G.711 ulaw codec. So that, I can play the transcoded stream in multicast radio channel using UDP.

Using c#, you could run ffmpeg.exe, which should let you:

  1. Take the Opus stream as input
  2. Transcode it to G.711u
  3. Forward it to your radio using UDP

Here is an example which does the last two steps:

//listen to the microphone, transcode to G.711u, send it over UDP to a multicast listener
    ffmpeg -f dshow -i audio="Microphone (Logitech USB Headset H340)" -ac 1 -ar 8000 -ab 64 -acodec pcm_mulaw -f rtp rtp://239.0.0.1:5656

And here are some other examples which may be of use:

//list input devices
    ffmpeg -list_devices true -f dshow -i dummy
        
//record microphone to mp3
    ffmpeg -f dshow -i audio="Microphone (Logitech USB Headset H340)" -c:a libmp3lame -ar 44100 -b:a 320k -ac 1 output1.mp3
                    
//play audio going to the radio
    ffplay rtp://239.0.0.1:5656

//play audio coming from the radio
    ffplay rtp://239.0.0.2:5656
                
//receive rtp multicast g.711 and save to mp3       
    ffmpeg -i rtp://239.0.0.1:5656 -filter:a "asetrate=8000" -acodec libmp3lame -ar 44100 output2.mp3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM