Decode and Play G729 on Windows
Wireshark has a very nice feature that lets you play and listen to G711 streams present in a captured traffic dump file, unfortunately Wirehsark is not able to directly decode G729
However, you can still manage to play and listen to the G729 stream by using the following steps
1) Open the capture file using wireshark
2) Go to Telephony > RTP > Show all streams
3) That will open up a windows listing all detected RTP streams, click on any stream
And select analyze
4) On the next windows click on ‘Save Payload” let the format be as ‘raw’, lets name the file as ‘stream.raw’
So by now you have an output file named stream.raw , you will get an error if you try to play this file using any media player
You, will need to first convert this saved stream to PCM format, a free decoder is available at http://www.voiceage.com/openinit_g729.php
Download and unzip the decoder files on your PC in folder C:\g729de and than follow the below steps
1) Copy the saved stream file ‘stream.raw’ to C:\g729de
2) Open-up DOS command prompt and cd to C:\g729de
3) Issue the following command in the command prompt window
va_g729_decoder.exe stream.raw stream.pcm
So now you have the G729 converted to a PCM file named ‘stream.pcm’
But the .pcm file contains 16-bit linear PCM samples at 8000 Hz. in Little-Endian format. To convert to .au format, you need to appened the 24 byte au header, and convert each PCM sample to network byte order (or Big-Endian). The following Perl Script as present on Wikeshak wiki page will be used to do the conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # # USAGE: perl pcm2au.pl inputFile outputFile $usage = "Usage: 'perl $0 <source PCM File> <destination AU File>' "; $srcFile = shift @ARGV || die $usage; $dstFile = shift @ARGV || die $usage; open(SRCFILE, "$srcFile") || die "Unable to open file: $!\n"; binmode SRCFILE; open(DSTFILE, "> $dstFile") || die "Unable to open file: $!\n"; binmode DSTFILE; ################################### # Write the AU header ################################### print DSTFILE ".snd"; $foo = pack("CCCC", 0,0,0,24); print DSTFILE $foo; $foo = pack("CCCC", 0xff,0xff,0xff,0xff); print DSTFILE $foo; $foo = pack("CCCC", 0,0,0,3); print DSTFILE $foo; $foo = pack("CCCC", 0,0,0x1f,0x40); print DSTFILE $foo; $foo = pack("CCCC", 0,0,0,1); print DSTFILE $foo; ############################# # swap the PCM samples ############################# while (read(SRCFILE, $inWord, 2) == 2) { @bytes = unpack('CC', $inWord); $outWord = pack('CC', $bytes[1], $bytes[0]); print DSTFILE $outWord; } close(DSTFILE); close(SRCFILE); |
Copy and save the above script in a text file named ‘pcm2au.pl’ in C:\g729de
Google for ‘Strawberry Perl” and install in on your PC
Now again fire-up the command prompt cd to C:\g729de
And issue the following command
perl pcm2au.pl stream.pcm steream.au
And that’s it, now you have successfully decoded the G729 on your Windows Computer and can play the stream.au file using any player like Windows Media Player or VLC player
I cant decode with the perl command, it just open a window “Windows Cannot Execute the Program …..”
There is a problem with line 12 of the script.
It should read –
open(DSTFILE, “> $dstFile”)
Looks like HTML has screwed this up
@Anderson
Have you installed Strawberry Perl ?
@Pat
Thanks for the tip, I have fixed that up
Hi,
Ran the command, and got the following error message
>perl pcm2au.pl stream.pcm stream.au
Search pattern no terminated at pcm2au.pl line 49.
@Charles
Sorry, WYSIWYG had messed up the code, please again copy the perl code from above and save it to the pcm2au.pl file. conversion will work now
You rock Dude.
This helped alot.
Thanks!
Hello,
I created a text file called pcm2au.pl which contains the perl script and put it in C:\G729.
Then, after I put the command cd C:\G729,
I am trying to put the command “perl pcm2au.pl stream.pcm steream.au”.
I get an error which says:
“Cant open perl script “pcm2au”: no such file or directory” –
can someone help me? I put the text file in the C:\G729… and I dont know what more to do..
Thnaks,
Ofek
Solved it..
Donwloaded Notepad C++ and it worked..
Thnaks a lot for this script!
you helped a lot:)
For converting PCM to WAV use SoX util.
In Windows OS systems click & type “Start->Run->cmd.exe”)
sox.exe -r 8k -c 1 rtpstream.pcm rtpstream.wav
Nothing else!
SoX home page:
http://sourceforge.net/projects/sox/