Convert RTP Payload (payload type 107, AMR-WB 16khz 1Channel) to .wav

99封情书 提交于 2020-07-10 10:29:10

问题


I'm working in Python 3.6 under Linux Ubuntu and I used the Scapy lib to extract data from a bin file which contained the following stack: IP/UDP/RTP. The RTP-PAYLOAD TYPE is 107 (dynamic), a=rtpmap:107 AMR-WB/16000/1.

I put it into a file in raw format and I called it src.aud, but it also wouldn't be a problem to put write it in hex. Now what do I have to do exactly to transform it into audio data format like .wav or .mp3 for example, which is on every computer?

I've already made an' effort with this file:

https://gist.github.com/ollyja/5fe34ba997d8fa8a3f6ff4fb883feca2

But there is a dependency on SILK audio decoder.

https://github.com/gaozehua/SILKCodec

But that's all written in C and I don't understand how to use it in my environment. Isn't there a simplier way or do I miss s.th. ?

Thanks for Your help


回答1:


You need to use a AMR decoder(ffmpeg - libavcodec) to decode the AMR payload data.

AMR decoder will give you PCM data, which can be written to a wav file (16 KHz).

AMR codec library can be used with ctypes python interface - Extending Python With C Libraries.




回答2:


Document RFC4867 (can easily found with google), chapters 4.3, 4.4 and 5. First it must be found out, if the RTP-PAYLOAD is bandwidth efficient (chapter 4.3) or octet aligned (4.4). In this case it's bandwidth efficient according 4.3.4. and it must be transformed according chapter 5, 5.1 and 5.3 before writing it into a file.amr or file.awb (both works).

The resulting file can be listened to with VLC-Media player and with 'Videos' of Linux Ubuntu. It can also be converted into all kinds of audiofiles by the online-converter 'convertio'.

https://convertio.co/it/


来源:https://stackoverflow.com/questions/61961965/convert-rtp-payload-payload-type-107-amr-wb-16khz-1channel-to-wav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!