voiprtppcaptelephonysipp

Convert an audio file into a pcap with codec G722


I need to convert an audio file (any common format) into a rtp stream saved in a .pcap file with G.722 Codec.

The generated .pcap file will be sent with SIPp using:

<exec play_pcap_audio="g722.pcap"/>

I know it is possible to send also .wav file with the following command, if the .wav is correctly encoded:

<exec rtp_stream="g711.wav"/>

But seems that is not possible to encode a .wav with G722.

There are multiple solutions on the web and SO on how to convert a .pcap into an audio file, but I'm actually looking for the opposite.


Solution

  • Steps to convert wav audio to .pcap file:

    1. Split audio to 20 ms chunks
    2. Encode each chunk with G.722 encoder
    3. Create RTP header for each encoded chunk
    4. Save RTP stream to .pcap

    I've never used SIPp, but if it can process encoded G.722 stream, then use ffmpeg for encoding:

    ffmpeg -i sample.wav -ar 16000 -acodec g722 sample.g722