I have several pcap files which captured by wireshark.
I collected that data from pcap file, payload data.
and saved it as file.
I tried to convert it to pcm data with this link
https://github.com/ToughmanL/EVS_CODEC
but it seems the data I collected is not EVS format.
please let me know how to get EVS codec from pcap file.
My understanding is that Stack Overflow is for programming questions, so here is an answer based on existing / example source code. First, in your screen cap Wireshark has found a commonly used form of EVS; the 61 byte packet payload length matches the EVS spec for 24400 bps primary mode, using compact format, which means (i) no ToC header byte in the payload, and (ii) only the payload size determines the bitrate. Second, to feed that to the 3GPP decoder you have to create a file with a MIME header and format, which is needed by the 3GPP reference program.
x86_mediatest.cpp (under the mediaTest folder in the Docker containers here) does this - it reads a pcap record-by-record, pulls out RTP payloads and writes them to a .cod file (coded format), including the MIME header. Running the 3GPP program on that file, with appropriate command line options then gives a PCM raw audio file you can convert to wav using sox, Audacity, Hypersignal, etc.
In x86_mediaTest.cpp, look for "if (pcap_extract) {". Also note the comment "If pcap RTP payloads are in CH (Compact Header) format, they are converted to FH (Header-Full) format by adding a ToC payload header byte". Which may explain why in your case, if you directly copied the compact header format payloads and fed them to the 3GPP decoder, it didn't work.
There is also a mediaMin program that will take the pcap on the command line and do the whole thing, generating a .wav file. You can use that for comparison and audio quality testing vs your code.
Disclaimer: I work for the company that created the mediaTest and mediaMin tools
Related
I have got this capture file (pcap) with RTP packets seems to be encoded by opus. In wireshark, analyzed the stream and saved as raw file.
Now I have got the .raw file of the audio. Using the opus tool from http://www.opus-codec.org/downloads/
I cannot decode it direct to wav because the file is raw,not .opus. I cannot encode it to .opus because this raw data is the extract of already encoded stream.
I just need to play this voice back. Any suggestions Please
As far as I know you won't be able to decode Opus stream extracted that way - framing information is lost. You need either write Wireshark module that would be able to decode opus or write another tool to extract stream from RTP into another container (typically OGG is used).
http://xiph.org/~giles/2012/rtpopus.c seems to be tool that you need.
Old question, but if anyone needs to decode Opus RTP packets, here is the solution:
PJSIP comes with a tool (pjsip-apps/src/samples/pcaputil.c) that does just that. It gets compiled by default, just make sure you have libopus-dev installed before you build PJSIP. Simply feed a pcap file with RTP packets to pcaputil and specify the codec on the command line (e.g. "opus/48000"). You will get the decoded audio as a PCM WAV file.
pcaputil can also decrypt SRTP packets (if given the key), however I could not get that to work and instead used srtp-decrypt to decrypt the packets, followed by Wireshark to convert the .txt output back to .pcap for feeding to PJSIP's pcaputil (see also https://www.acritelli.com/hacking-voip-decrypting-sdes-protected-srtp-phone-calls/).
Hello I am supposed to write a utility that will extract an opus encoded audio payload from RTP packets which I will read from a pcap dumpfile. The utility should also have the functionality that can be used to decode the payload that I am extracting from the rtp packets and convert it to a .wav file.
Currently I have written a code that extracts the payload from the rtp packets and dumps it into a file "log.opus". However I am stuck at this point. How should I proceed with writing the decoder logic?
I am working on Windows platform and am using winpcap library and libopus.
I suggest you have a look at this trivial example I created to show how to use Opus:
http://git.xiph.org/?p=opus.git;a=blob;f=doc/trivial_example.c
You'll want to keep just the decoder part. There's also the API documentation for more details:
http://www.opus-codec.org/docs/html_api-1.1.0/index.html
I have a text file contaning payload of RTP packets (in hex,coded with GSM\ opus\speex ) belong to a VoIP conversation, does anyone know how to convert this file into a .wav audio file?
I'm using windows.
Thanks
.wav is just an file container which you can have an any codec format and makes the player to recognize the codec inside. Refer Wiki: WAV and for more technical details refer WaveFormat. And It just wrappers the raw codec content. If you have experience in C program, there are open source available to convert one codec to PCM. Since PCM is the raw audio data in 16 bit format.
But I suggest an solution but don't know it will met your requirement.
install latest wireshark
using wireshark capture the RTP packets.
Select UDP packet and Right click and choose Decode As option
Select Transport tab and choose RTP protocol
Now you can see RTP packet with right codec
Go to Telephony -> RTP -> Stream analysis -> Save the RTP Payload as .raw
At this stage the codec data is available in .raw file format.
There are open software are available are available such as SoX, ffmpeg etc...
From there are you can covert .raw to .wav format.
After that you can play in VLC (PCM, GSM, ADPM, Alaw , uLaw) or any other supported player (Amr)
You won't find Speex, g729 since these are paid
How can we distinguish between PCM and BWF format?
Is it necessary for BWF to have "bext" header?
I have some streams that don't have "bext" header but contains "JUNK" header... Are these files BWF files?
Thanks you.
The JUNK chunk is reserved space to allow a BWF file to be converted into an RF64 file on the fly if the size goes over 4GB. The JUNK chunk is the same size as a ds64 chunk, and will be replaced with a ds64 chunk if the conversion to RF64 is needed. Read more about it here.
My reading of the BWF spec is that you have to have a bext chunk for it to be a BWF.
As far as I know, a broadcast wave file will have the 'bext' header extension.
If a file does not have the 'bext' header extension, it will be a normal WAV/AIFF or whatever file.
Broadcast wave headers are used especially if you want to give a file more information about itself in the header which isn't to be seen immediately from its name.
For playing back, this info isn't necessary to know. Just if you want to show or search the meta information somehow.
PCM isn't a file format. All files that handle uncompressed data are PCM files.
Such as WAV/BWF, AIFF or SD2 for example.
With encoded files like MP3 or AAC you get the raw PCM values after decoding.
Yes. The 'bext' chunk is what distinguishes a BWF file from a wav file.
Some manufacturers actually use '.bwf' as a file extension but mostly the '.wav' extension will be used. It is only the presence of this chunk that makes the difference.
Other chunks can also be present and a well designed player will ignore chunks that it doesn't recognize.
Generally the 'data' chunk containing the audio data will be the last one in the file. However I have seen a few examples of other chunks, usually xml metadata, appearing after the 'data' chunk. This confuses some players.
For more information search for tech3285.pdf from the European Broadcasting Union website (tech.EBU.ch).
I need to find the codec of an audio file. How can I do this?
Do I need to write code to do this or is there a simpler way?
Please help me. If possible share helpful links.
The good old file utility will reveal lots of information about audio files, sometimes including the codec:
$ file X.wav
X.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
#bhebsquines
"It is important to distinguish between a file format and an audio codec. A codec performs the encoding and decoding of the raw audio data while the data itself is stored in a file with a specific audio file format. Although most audio file formats support only one type of audio data (created with an audio coder), a multimedia container format (as Matroska or AVI) may support multiple types of audio and video data." - http://en.wikipedia.org/wiki/Audio_file_format
The application gspot does a good job of pulling codecs from audio and video files.
http://www.headbands.com/gspot/
run it and drag a file into the window. It will pull all of the data from there. Note that some audio files will not display a codec as they are made from "Raw" audio.
You can identify your codec by extenion name itself example file1audio.mp3 or fileaudio.avi, .mp3, .avi will be your file type or codec, you can use k-lite codec pack for your different type audio format. use this link http://www.free-codecs.com/download/k_lite_codec_pack.htm