Transcoding of audio and video codec is complex and costly it is fulfilled with the giant legacy telecom company. Please follow the below example if you want to transcode using opensource and free of cost.
Step 1 - Launch a VM with ubuntu 18.04
Step 2 - Login and Run below command
#apt update && apt-get install -y debhelper=12.1.1ubuntu1~ubuntu18.04.1 dh-autoreconf libmysqlclient-dev iptables-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libevent-dev libglib2.0-dev libhiredis-dev libjson-glib-dev libpcap-dev libpcre3-dev libsystemd-dev libssl-dev libswresample-dev libxmlrpc-core-c3-dev markdown gperf libbencode-perl libdigest-crc-perl libcrypt-openssl-rsa-perl libcrypt-rijndael-perl libdigest-hmac-perl libio-multiplex-perl libio-socket-inet6-perl libnet-interface-perl libsocket6-perl default-libmysqlclient-dev libiptc-dev libspandsp-dev libhiredis-dev libjson-glib-dev libpcap0.8-dev libpcre3-dev libssl-dev libswresample-dev libsystemd-dev git gcc g++ flex bison libmysqlclient-dev make autoconf libssl-dev libcurl4-openssl-dev libxml2-dev libpcre3-dev libxmlrpc-core-c3-dev zlib1g-dev fakeroot unzip redis-server init-system-helpers sngrep wget libconfig-tiny-perl dkms module-assistant nfs-common keyutils libnfsidmap2 libtirpc1 nfs-common rpcbind keyutils libnfsidmap2 libtirpc1 nfs-common rpcbind watchdog
Step 3 - Install Kamailio
#cd /usr/local/src && git clone --depth 1 --no-single-branch https://github.com/kamailio/kamailio kamailio
#cd kamailio && git checkout -b 5.3 origin/5.3
#make include_modules="db_mysql dialplan" cfg
#make PREFIX="/usr/local/kamailio-5.3" include_modules="db_mysql dialplan" cfg
#make all
Step 4: Install RTPEngine with G729 supports
#cd /usr/local/src && git clone https://github.com/sipwise/rtpengine.git
#cd rtpengine && git checkout mr8.2.1.1
#cd /usr/local/src
VER=1.0.4 && curl https://codeload.github.com/BelledonneCommunications/bcg729/tar.gz/$VER >bcg729_$VER.orig.tar.gz
#tar zxf bcg729_$VER.orig.tar.gz && cd bcg729-$VER
#git clone https://github.com/ossobv/bcg729-deb.git debian
#dpkg-buildpackage -us -uc -sa
#cd ..
#dpkg -i libbcg729-0_1.0.4-0osso3+deb9_amd64.deb
#dpkg -i libbcg729-dev_1.0.4-0osso3+deb9_amd64.deb
#dpkg -i libbcg729-0-dbg_1.0.4-0osso3+deb9_amd64.deb
#cd rtpengine/
#dpkg-checkbuilddeps
#dpkg-buildpackage -rfakeroot
#cd ..
#apt-get -f install && apt --fix-broken install
#dpkg -i ngcp-rtpengine-daemon_8.2.1.1+0~mr8.2.1.1_amd64.deb
#dpkg -i ngcp-rtpengine-iptables_8.2.1.1+0~mr8.2.1.1_amd64.deb
#dpkg -i ngcp-rtpengine-kernel-dkms_8.2.1.1+0~mr8.2.1.1_all.deb
#dpkg -i ngcp-rtpengine-kernel-source_8.2.1.1+0~mr8.2.1.1_all.deb
#dpkg -i ngcp-rtpengine-recording-daemon_8.2.1.1+0~mr8.2.1.1_amd64.deb
#dpkg --install ngcp-rtpengine-utils_8.2.1.1+0~mr8.2.1.1_all.deb
#dpkg -i ngcp-rtpengine_8.2.1.1+0~mr8.2.1.1_all.deb
#dpkg -i ngcp-rtpengine-kernel-source_8.2.1.1+0~mr8.2.1.1_all.deb
#dpkg -i ngcp-rtpengine-daemon-dbgsym_8.2.1.1+0~mr8.2.1.1_amd64.ddeb
# rtpengine --codecs
PCMA: fully supported
PCMU: fully supported
G723: fully supported
G722: fully supported
QCELP: supported for decoding only
G729: fully supported
speex: fully supported
GSM: fully supported
iLBC: not supported
opus: fully supported
vorbis: fully supported
ac3: fully supported
eac3: fully supported
ATRAC3: supported for decoding only
ATRAC-X: supported for decoding only
EVRC: supported for decoding only
EVRC0: supported for decoding only
EVRC1: supported for decoding only
AMR: supported for decoding only
AMR-WB: supported for decoding only
PCM-S16LE: fully supported
MP3: fully supported
Step 5: Modify Kamailio configuration
...if (is_method("INVITE")) { if (has_body("application/sdp")) { rtpengine_manage("codec-mask-all codec-transcode-PCMA"); ...
For any support please contact us at support@pstncall.com. www.pstncall.com