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

Related posts:

  1. How to run a FTP script in Windows? Not only Windows has a built-in command line FTP utility...
  2. Play mp3 in Linux If you want to play MP3’s in Linux than a...
  3. Creating Tar.gz files in Windows You can open and extract the content from gzipped in...
  4. Windows Standby / Hibernation & Network Connections Disappear I had been having this problems for many months, whenever...
  5. Windows reboots during booting Once again Windows Troubles, last week I turned off the...
  6. How to Show arp entries in Windows arp –a Displays the ARP entries in Windows by checking...

Trackback

5 comments untill now

  1. Anderson @ 2010-06-09 21:10

    I cant decode with the perl command, it just open a window “Windows Cannot Execute the Program …..”

  2. There is a problem with line 12 of the script.

    It should read –

    open(DSTFILE, “> $dstFile”)

    Looks like HTML has screwed this up

  3. @Anderson
    Have you installed Strawberry Perl ?

    @Pat
    Thanks for the tip, I have fixed that up

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

  5. @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

Add your comment now