本文介绍了将RTP有效负载(有效负载类型107,AMR-WB 16khz 1Channel)转换为.wav的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Linux Ubuntu下使用Python 3.6进行工作,我使用了Scapy库从包含以下堆栈的bin文件中提取数据:IP / UDP / RTP。 RTP-PAYLOAD TYPE是107(动态),a = rtpmap:107 AMR-WB / 16000/1。

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.

我将其以原始格式放入文件中,称为 src.aud ,但是将其写成十六进制也不是问题。现在我该怎么做才能将其转换为音频数据格式,例如,每台计算机上的.wav或.mp3格式?

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

但是对SILK有依赖性音频解码器。

But there is a dependency on SILK audio decoder.

https://github.com/gaozehua/SILKCodec

但这都是用C编写的,我不知道如何在我的环境中使用它。是不是有一个简单的方法,或者我想念s.th。 ?

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. ?

感谢您的帮助

推荐答案

文档RFC4867(可以轻松,请参阅第4.3、4.4和5章。首先,必须确定RTP-PAYLOAD是带宽有效的(第4.3章)还是八位字节对齐(4.4)。在这种情况下,它的带宽效率达到了4.3.4的要求。并且必须先根据第5、5.1和5.3章对其进行转换,然后再将其写入file.amr或file.awb(两者均有效)。

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).

可以使用VLC-收听生成的文件媒体播放器和Linux Ubuntu的视频。但也可以通过在线转换器 convertio将其转换为各种音频文件。

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

https://convertio.co/it/

在Python中执行此操作的直接方法是使用FFmpeg包装的Python库ffmpy。

A direct way to do that in Python is the Python library ffmpy that has FFmpeg wrapped.

https://ffmpy.readthedocs.io/en/latest/

在快速入门下,有一个解决问题的示例。

Under Quickstart there is an' example that resolves the problem.

这篇关于将RTP有效负载(有效负载类型107,AMR-WB 16khz 1Channel)转换为.wav的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 10:53