This wiki has been migrated to https://gitlab.com/wireshark/wireshark/-/wikis/home and is now deprecated. Please use that site instead.
Differences between revisions 2 and 16 (spanning 14 versions)
Revision 2 as of 2007-06-25 11:57:36
Size: 2429
Editor: gty
Comment:
Revision 16 as of 2019-06-30 15:57:43
Size: 3465
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
Line 5: Line 4:
G.729 is another commonly used codec used in Voice over IP. This procedure will allow you to decode this type of stream. In order to run the procedure, you will first need to obtain the Open G.729 decoder, available for free from !VoiceAge http://www.voiceage.com/openinit_g729.php. Note that this procedure works either under Windows or under Linux with Wine. G.729 is another commonly used codec used in Voice over IP. This procedure will allow you to decode this type of stream. In order to run the procedure, you will first need to obtain the Open G.729 decoder, available for free from https://codecpro.com/en/codecs/page/downloads
Line 7: Line 6:
 1. In Wireshark, use menu "Statistics -> RTP -> Show All Streams". Select the desired stream and press "Analyze". Note that this procedure works either under Windows or under Linux with Wine.
Line 9: Line 8:
 2. In the next dialog screen, press "Save Payload...". Save options are Format = .raw and Channel = forward. Name file sample.raw.  1. In Wireshark, use menu "Telephony -> RTP -> Show All Streams". Select the desired stream and press "Analyze".
Line 11: Line 10:
 3. Convert the .raw file to .pcm format using the Open G.729 decoder. '''Syntax:''' va_g729_decoder.exe sample.raw sample.pcm. Or for Linux: wine va_g729_decoder.exe sample.raw sample.pcm.  1. In the next dialog screen, press "Save Payload...". Save options are Format = .raw and Channel = forward. Name file sample.raw.
Line 13: Line 12:
 4. The .pcm file contains 16-bit linear PCM samples at 8000 hz. Note that each sample is in Little-Endian format. To convert to .au format, all you need to do is prepend the 24 byte au header, and convert each PCM sample to network byte order (or Big-Endian). The following Perl Script will do the trick.  1. Convert the .raw file to .pcm format using the Open G.729 decoder. '''Syntax:''' cp_g729_decoder.exe sample.raw sample.pcm. Or for Linux: wine cp_g729_decoder.exe sample.raw sample.pcm.

 1
. The .pcm file contains 16-bit linear PCM samples at 8000 Hz. Note that each sample is in Little-Endian format. To convert to .au format, all you need to do is prepend the 24 byte au header, and convert each PCM sample to network byte order (or Big-Endian). The following Perl Script will do the trick.
Line 22: Line 23:
$srcFile = shift @ARGV || die $usage;
$dstFile = shift @ARGV || die $usage;
$srcFile = shift or die $usage;
$dstFile = shift or die $usage;
Line 25: Line 26:
open(SRCFILE, "$srcFile") || die "Unable to open file: $!\n"; open(SRCFILE, "$srcFile") or die "Unable to open file: $!\n";
Line 28: Line 29:
open(DSTFILE, "> $dstFile") || die "Unable to open file: $!\n"; open(DSTFILE, "> $dstFile") or die "Unable to open file: $!\n";
Line 66: Line 67:
As will this Python script:
Line 67: Line 69:
{{{
import sys
import struct
import os

if len(sys.argv) != 2:
    print("Usage: 'python pcm2au.py <Source PCM File>'")
    sys.exit(1)
srcFilename = sys.argv[1]
dstFilename = '%s.au' % os.path.splitext(srcFilename)[0]
with open(srcFilename, 'r+b') as srcFile, open(dstFilename, 'w+b') as dstFile:
    ###################################
    # Write the AU header
    ###################################
    dstFile.write(b'.snd')
    dstFile.write(struct.pack('BBBB', 0,0,0,24))
    dstFile.write(struct.pack('BBBB', 0xff,0xff,0xff,0xff))
    dstFile.write(struct.pack('BBBB', 0,0,0,3))
    dstFile.write(struct.pack('BBBB', 0,0,0x1f,0x40))
    dstFile.write(struct.pack('BBBB', 0,0,0,1))

    #############################
    # swap the PCM samples
    #############################
    while True:
        data = srcFile.read(2)
        if len(data) == 2:
            word = struct.unpack('<H', data)[0]
            dstFile.write(struct.pack('>H', word))
        else:
            break
}}}

How To Decode G.729

Wireshark will currently allow you to save the G.711 RTP payload information in .au file format. This allows you to play back a captured conversation.

G.729 is another commonly used codec used in Voice over IP. This procedure will allow you to decode this type of stream. In order to run the procedure, you will first need to obtain the Open G.729 decoder, available for free from https://codecpro.com/en/codecs/page/downloads

Note that this procedure works either under Windows or under Linux with Wine.

  1. In Wireshark, use menu "Telephony -> RTP -> Show All Streams". Select the desired stream and press "Analyze".

  2. In the next dialog screen, press "Save Payload...". Save options are Format = .raw and Channel = forward. Name file sample.raw.
  3. Convert the .raw file to .pcm format using the Open G.729 decoder. Syntax: cp_g729_decoder.exe sample.raw sample.pcm. Or for Linux: wine cp_g729_decoder.exe sample.raw sample.pcm.

  4. The .pcm file contains 16-bit linear PCM samples at 8000 Hz. Note that each sample is in Little-Endian format. To convert to .au format, all you need to do is prepend the 24 byte au header, and convert each PCM sample to network byte order (or Big-Endian). The following Perl Script will do the trick.

#
# USAGE: perl pcm2au.pl inputFile outputFile


$usage = "Usage: 'perl $0 <Source PCM File> <Destination AU File>' ";

$srcFile = shift or die $usage;
$dstFile = shift or die $usage;

open(SRCFILE, "$srcFile") or die "Unable to open file: $!\n";
binmode SRCFILE;

open(DSTFILE, "> $dstFile") or 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);

As will this Python script:

import sys
import struct
import os

if len(sys.argv) != 2:
    print("Usage: 'python pcm2au.py <Source PCM File>'")
    sys.exit(1)
srcFilename = sys.argv[1]
dstFilename = '%s.au' % os.path.splitext(srcFilename)[0]
with open(srcFilename, 'r+b') as srcFile, open(dstFilename, 'w+b') as dstFile:
    ###################################
    # Write the AU header
    ###################################
    dstFile.write(b'.snd')
    dstFile.write(struct.pack('BBBB', 0,0,0,24))
    dstFile.write(struct.pack('BBBB', 0xff,0xff,0xff,0xff))
    dstFile.write(struct.pack('BBBB', 0,0,0,3))
    dstFile.write(struct.pack('BBBB', 0,0,0x1f,0x40))
    dstFile.write(struct.pack('BBBB', 0,0,0,1))

    #############################
    # swap the PCM samples
    #############################
    while True:
        data = srcFile.read(2)
        if len(data) == 2:
            word = struct.unpack('<H', data)[0]
            dstFile.write(struct.pack('>H', word))
        else:
            break


CategoryHowTo

HowToDecodeG729 (last edited 2019-12-27 20:44:25 by JiriNovak)